From a2fcfadba2169cd062b9fba5a07ffda3712d60b7 Mon Sep 17 00:00:00 2001 From: alisa Date: Wed, 24 Apr 2024 10:08:19 +0800 Subject: [PATCH] ci: update website deployment action to support deployment_environment --- .github/workflows/deploy-website.yaml | 35 +++++++++++++++++++++------ 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy-website.yaml b/.github/workflows/deploy-website.yaml index 44bbc841ce..a9a7d22407 100644 --- a/.github/workflows/deploy-website.yaml +++ b/.github/workflows/deploy-website.yaml @@ -1,14 +1,15 @@ -name: Build and Deploy +name: Deploy Website on: - release: - types: - - published + push: + branches: + - master + - dev workflow_dispatch: inputs: - deploy-to-azure: - description: "部署到Azure" - default: true + deploy-to-prod-env: + description: "Deploy to production environment" + default: false required: true type: boolean @@ -42,6 +43,24 @@ jobs: run: pnpm run build working-directory: "./website" + - name: Set deployment environment + id: set-deployment-env + run: | + if [[ "${{ github.event_name }}" != "workflow_dispatch" ]]; then + if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then + echo "AZURE_TARGET_ENV=Production" >> $GITHUB_ENV + else + echo "AZURE_TARGET_ENV=dev" >> $GITHUB_ENV + fi + else + if [[ "${{ github.event.inputs.deploy-to-prod-env }}" == "true" ]]; then + echo "AZURE_TARGET_ENV=Production" >> $GITHUB_ENV + else + echo "AZURE_TARGET_ENV=dev" >> $GITHUB_ENV + fi + fi + echo "Deployment environment: ${{ env.AZURE_TARGET_ENV }}" + - name: Deploy to Azure id: deploy uses: Azure/static-web-apps-deploy@v1 @@ -49,7 +68,7 @@ jobs: azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_MAA_WEBSITE }} repo_token: ${{ secrets.GITHUB_TOKEN }} action: "upload" - production_branch: "master" + deployment_environment: ${{ env.AZURE_TARGET_ENV }} app_location: "./website/dist" api_location: "" skip_app_build: true