name: Deploy Webapp (Blue-Green) on: workflow_dispatch: inputs: image_tag: description: '镜像tag,留空则使用commit短哈希' required: false jobs: deploy: runs-on: deploy-host steps: - uses: actions/checkout@v4 - name: 确定镜像tag id: vars run: | TAG="${{ github.event.inputs.image_tag }}" [ -z "$TAG" ] && TAG=$(git rev-parse --short HEAD) echo "tag=$TAG" >> "$GITHUB_OUTPUT" - name: 构建镜像 run: | docker build -t im-webapp:${{ steps.vars.outputs.tag }} \ --build-arg TINODE_API_KEY="${{ secrets.TINODE_API_KEY }}" . - name: 蓝绿部署 run: | IMAGE=im-webapp:${{ steps.vars.outputs.tag }} /opt/apps/im-webapp/deploy.sh