ci(deploy): modernize Azure Static Web Apps workflow #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docs Deploy Azure Static Web Apps | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: [opened, synchronize, reopened, closed] | |
| branches: | |
| - main | |
| concurrency: | |
| group: docs-deploy-azure-static-web-apps-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| env: | |
| NODE_VERSION: "22" | |
| jobs: | |
| build_and_deploy: | |
| if: github.event.action != 'closed' | |
| name: Build and deploy docs snapshot | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build docs | |
| run: npm run build:ci | |
| env: | |
| CLARITY_PROJECT_ID: ${{ secrets.CLARITY_PROJECT_ID }} | |
| - name: Upload prebuilt docs to Azure Static Web Apps | |
| id: deploy | |
| uses: Azure/static-web-apps-deploy@v1 | |
| with: | |
| azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| action: upload | |
| app_location: dist | |
| skip_app_build: true | |
| skip_api_build: true | |
| close_pull_request: | |
| if: github.event_name == 'pull_request' && github.event.action == 'closed' | |
| name: Close Azure Static Web Apps pull request preview | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Close pull request preview | |
| uses: Azure/static-web-apps-deploy@v1 | |
| with: | |
| azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | |
| action: close |