Switch to manual trigger (workflow_dispatch)
This commit is contained in:
+13
-19
@@ -1,8 +1,15 @@
|
||||
name: lpt-fe Build & Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: '部署环境'
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- dev
|
||||
- prod
|
||||
|
||||
env:
|
||||
REGISTRY: 192.168.123.199:5000
|
||||
@@ -14,25 +21,12 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set environment
|
||||
id: env
|
||||
run: |
|
||||
if [ "${{ github.ref_name }}" = "master" ]; then
|
||||
echo "suffix=prod" >> $GITHUB_OUTPUT
|
||||
echo "namespace=lpt-prod" >> $GITHUB_OUTPUT
|
||||
echo "build_mode=production" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "suffix=dev" >> $GITHUB_OUTPUT
|
||||
echo "namespace=lpt-dev" >> $GITHUB_OUTPUT
|
||||
echo "build_mode=development" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Build & Push Docker image
|
||||
run: |
|
||||
docker build --build-arg BUILD_MODE=${{ steps.env.outputs.build_mode }} \
|
||||
-t $REGISTRY/$APP:${{ steps.env.outputs.suffix }} .
|
||||
docker push $REGISTRY/$APP:${{ steps.env.outputs.suffix }}
|
||||
docker build --build-arg BUILD_MODE=${{ inputs.environment == 'prod' && 'production' || 'development' }} \
|
||||
-t $REGISTRY/$APP:${{ inputs.environment }} .
|
||||
docker push $REGISTRY/$APP:${{ inputs.environment }}
|
||||
|
||||
- name: Deploy to K8s
|
||||
run: |
|
||||
kubectl rollout restart deployment/$APP -n ${{ steps.env.outputs.namespace }}
|
||||
kubectl rollout restart deployment/$APP -n lpt-${{ inputs.environment }}
|
||||
|
||||
Reference in New Issue
Block a user