ci: update website deployment action to support deployment_environment

This commit is contained in:
alisa
2024-04-24 10:08:19 +08:00
parent c2bd0133ba
commit a2fcfadba2

View File

@@ -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