Repository navigation
fix(unit-2.3): 以生活對話銜接二氧化碳收集 #2530
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: Deploy demo page | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| publish_when_branch_build_failed: | |
| description: Publish with Actions after the branch publisher has failed | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: pages-main-single | |
| cancel-in-progress: false | |
| jobs: | |
| publishing-source: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pages: read | |
| outputs: | |
| actions: ${{ steps.source.outputs.actions }} | |
| steps: | |
| - name: Select the configured publisher or explicit manual recovery | |
| id: source | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PAGES_SOURCE_REPO: ${{ github.repository }} | |
| PAGES_MANUAL_PUBLISH: ${{ github.event_name == 'workflow_dispatch' && inputs.publish_when_branch_build_failed }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| pages_source=$(gh api "repos/${PAGES_SOURCE_REPO}/pages" --jq '.build_type') | |
| if [[ "$pages_source" == workflow || "$PAGES_MANUAL_PUBLISH" == true ]]; then | |
| echo 'actions=true' >> "$GITHUB_OUTPUT" | |
| if [[ "$pages_source" != workflow ]]; then | |
| echo '::notice::Explicit manual recovery requested after branch publication failed.' | |
| fi | |
| else | |
| echo 'actions=false' >> "$GITHUB_OUTPUT" | |
| echo '::notice::Pages uses the branch publisher; automatic Actions publication is skipped.' | |
| fi | |
| deploy: | |
| needs: publishing-source | |
| if: needs.publishing-source.outputs.actions == 'true' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pages: write | |
| id-token: write | |
| deployments: write | |
| actions: read | |
| steps: | |
| - name: Check out demo page | |
| uses: actions/checkout@v4 | |
| - name: Configure GitHub Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload the page | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: . | |
| - name: Identify and back up a completed prior Pages record | |
| id: previous | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PAGES_LOCK_DIR: ${{ runner.temp }}/pages-lock | |
| run: node .github/scripts/pages-lock.mjs plan | |
| - name: Archive the prior record before repair | |
| if: steps.previous.outputs.found == 'true' | |
| id: archive | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pages-record-backup-${{ github.run_id }}-${{ github.run_attempt }} | |
| path: ${{ runner.temp }}/pages-lock/completed-deployment.json | |
| if-no-files-found: error | |
| retention-days: 90 | |
| - name: Release only the archived completed record | |
| if: steps.previous.outputs.found == 'true' && steps.archive.outcome == 'success' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PAGES_LOCK_DIR: ${{ runner.temp }}/pages-lock | |
| PAGES_LOCK_ARCHIVE_ID: ${{ steps.archive.outputs.artifact-id }} | |
| run: node .github/scripts/pages-lock.mjs apply | |
| - name: Publish the page | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |