name: lpt-fe Build & Deploy on: workflow_dispatch: inputs: environment: description: '部署环境' required: true type: choice options: - dev - prod env: REGISTRY: 192.168.123.199:5000 APP: lpt-fe REPO_URL: http://git.cat-shark.xyz/cat-shark/lpt-fe.git jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout code run: | git clone $REPO_URL . git checkout ${{ github.sha }} - name: Build & Push Docker image run: | apt-get update -qq apt-get install -y -qq docker.io TAG=${{ github.sha }} docker build \ --build-arg BUILD_MODE=${{ inputs.environment == 'prod' && 'production' || 'development' }} \ -t $REGISTRY/$APP:$TAG \ -t $REGISTRY/$APP:${{ inputs.environment }} . docker push $REGISTRY/$APP:$TAG docker push $REGISTRY/$APP:${{ inputs.environment }} - name: Setup kubectl run: | curl -sLO "https://dl.k8s.io/release/v1.36.0/bin/linux/amd64/kubectl" chmod +x kubectl mv kubectl /usr/local/bin/ mkdir -p ~/.kube echo "${{ secrets.KUBECONFIG_B64 }}" | base64 -d > ~/.kube/config - name: Deploy to K8s run: | TAG=${{ github.sha }} kubectl set image deployment/$APP $APP=$REGISTRY/$APP:$TAG -n lpt-${{ inputs.environment }} kubectl rollout status deployment/$APP -n lpt-${{ inputs.environment }}