mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 01:40:46 +08:00
110 lines
2.9 KiB
YAML
110 lines
2.9 KiB
YAML
name: MaaWebsite Workflow
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "master"
|
|
- "dev"
|
|
paths:
|
|
- ".github/workflows/website-workflow.yml"
|
|
- "docs/**"
|
|
- "website/**"
|
|
pull_request:
|
|
paths:
|
|
- ".github/workflows/website-workflow.yml"
|
|
- "docs/**"
|
|
- "website/**"
|
|
workflow_dispatch:
|
|
inputs:
|
|
deploy-to-prod-env:
|
|
description: "Deploy to production environment"
|
|
default: false
|
|
required: true
|
|
type: boolean
|
|
|
|
jobs:
|
|
build:
|
|
timeout-minutes: 20
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
show-progress: false
|
|
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9
|
|
run_install: false
|
|
|
|
- name: Setup Node.js environment
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: pnpm
|
|
cache-dependency-path: "./website/pnpm-lock.yaml"
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
working-directory: "./website"
|
|
|
|
- name: Build
|
|
run: pnpm run build
|
|
working-directory: "./website"
|
|
|
|
- name: Upload artifact to GitHub
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: "./website/dist"
|
|
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
if: github.event_name != 'pull_request'
|
|
steps:
|
|
- name: Download website artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: dist
|
|
|
|
- name: Set deployment environment
|
|
id: set-deployment-env
|
|
run: |
|
|
if [[ "${{ github.event_name }}" != "workflow_dispatch" && "${{ github.ref }}" == "refs/heads/master" ]] || [[ "${{ github.event.inputs.deploy-to-prod-env }}" == "true" ]]; then
|
|
echo "AZURE_TARGET_ENV=prod" >> $GITHUB_ENV
|
|
else
|
|
echo "AZURE_TARGET_ENV=dev" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Show environment
|
|
run: echo ${{ env.AZURE_TARGET_ENV }}
|
|
|
|
- name: Deploy to Azure (prod)
|
|
id: deploy-prod
|
|
uses: Azure/static-web-apps-deploy@v1
|
|
if: env.AZURE_TARGET_ENV == 'prod'
|
|
with:
|
|
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_MAA_WEBSITE }}
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
action: "upload"
|
|
app_location: "."
|
|
api_location: ""
|
|
skip_app_build: true
|
|
skip_api_build: true
|
|
|
|
- name: Deploy to Azure (dev)
|
|
id: deploy-dev
|
|
uses: Azure/static-web-apps-deploy@v1
|
|
if: env.AZURE_TARGET_ENV == 'dev'
|
|
with:
|
|
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_MAA_WEBSITE }}
|
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
action: "upload"
|
|
deployment_environment: dev
|
|
app_location: "."
|
|
api_location: ""
|
|
skip_app_build: true
|
|
skip_api_build: true
|