Repository navigation
github pages #1620
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
| #******************************************************************************* | |
| # gh-pages.yml | |
| # | |
| # Github Workflow to deploy Interlisp.org. | |
| # | |
| # Interlisp.org is a Hugo based static website that contains a | |
| # detailed bibliography maintained using Zotero (https://www.zotero.org/groups/2914042/interlispwww.zotero.org/). | |
| # | |
| # This workflow consists of several jobs: | |
| # | |
| # validate-docs - ensure README.md references the correct Hugo version | |
| # hugo-version - expose the Hugo version as a job output | |
| # build - build the website and run the full test suite using the | |
| # org-level reusable workflow; also checks the Zotero | |
| # bibliography version (skipping the build on scheduled | |
| # runs when it is unchanged) | |
| # (Interlisp/shared-workflows/.github/workflows/build-site.yml) | |
| # preview - trigger a per-PR staging preview in | |
| # Interlisp/Interlisp.staging (skips on fork PRs or when | |
| # the STAGING_APP_ID variable is unset) | |
| # deploy - deploy the built site to GitHub Pages | |
| # | |
| # The workflow is executed either on a push or via scheduled run times. When | |
| # started at a scheduled run time we only do a deploy if the cached bibliography | |
| # is no longer current. On a push, we always verify the the current | |
| # bibliography is loaded and deploy a new version of the website. | |
| # | |
| # 2023-10-20 Bill Stumbo | |
| # | |
| # Copyright 2023 by Interlisp.org | |
| # | |
| # ****************************************************************************** | |
| name: github pages | |
| on: | |
| push: | |
| branches: | |
| - main # Set a branch to deploy | |
| pull_request: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: "0 3 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages-${{ github.ref }} | |
| cancel-in-progress: true | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| HUGO_VERSION: 0.155.3 | |
| jobs: | |
| # ---------------------------------------------------------------------------- | |
| # Validate that README.md references the correct Hugo version. | |
| # Only runs on push/pull_request, not scheduled runs. | |
| # | |
| validate-docs: | |
| if: github.event_name == 'push' || github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Check Hugo version consistency | |
| run: | | |
| echo "Checking README.md for Hugo version $HUGO_VERSION" | |
| # Check badge | |
| if ! grep -q "badge/Hugo-${HUGO_VERSION}" README.md; then | |
| echo "::error::README.md badge does not reference Hugo version $HUGO_VERSION" | |
| FAILED=1 | |
| fi | |
| # Check download URL | |
| if ! grep -q "hugo_extended_${HUGO_VERSION}_linux-amd64.deb" README.md; then | |
| echo "::error::README.md download URL does not reference Hugo version $HUGO_VERSION" | |
| FAILED=1 | |
| fi | |
| if [ "$FAILED" = "1" ]; then | |
| echo "Update README.md to use Hugo version $HUGO_VERSION" | |
| exit 1 | |
| fi | |
| echo "README.md Hugo version references are consistent" | |
| # ---------------------------------------------------------------------------- | |
| # Expose the Hugo version from the workflow environment as a job output. | |
| # The env context is not available in a reusable workflow's `with:` block, | |
| # so the version is surfaced here instead. Keeping it in the workflow `env` | |
| # means version bumps are ordinary, reviewed pull requests. | |
| # | |
| hugo-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ env.HUGO_VERSION }} | |
| steps: | |
| - name: Verify Hugo version is set | |
| env: | |
| VERSION: ${{ env.HUGO_VERSION }} | |
| run: | | |
| [[ -n "$VERSION" ]] || { echo "::error::HUGO_VERSION is empty"; exit 1; } | |
| echo "Hugo version: $VERSION" | |
| # ---------------------------------------------------------------------------- | |
| # Build the website using the org-level reusable workflow. This job is | |
| # conditional, we will always run it on a push or if on a scheduled run the | |
| # cache was determined to be out of date. | |
| # | |
| build: | |
| needs: [validate-docs, hugo-version] | |
| if: always() && (needs.validate-docs.result == 'success' || needs.validate-docs.result == 'skipped') && (needs.hugo-version.result == 'success') | |
| uses: Interlisp/shared-workflows/.github/workflows/build-site.yml@main | |
| with: | |
| hugo-version: ${{ needs.hugo-version.outputs.version }} | |
| hugo-environment: ${{ vars.HUGO_ENVIRONMENT || 'production' }} | |
| skip-if-fresh: ${{ github.event_name == 'schedule' }} | |
| # ---------------------------------------------------------------------------- | |
| # Trigger a per-PR staging preview in Interlisp/Interlisp.staging. Skips on | |
| # fork pull requests and when the GitHub App credentials are not configured, | |
| # so the workflow remains green during rollout. The Hugo version is passed | |
| # as a dispatch input (a step can read the env context, unlike a reusable | |
| # workflow call), keeping gh-pages.yml's env the single source of truth. | |
| # | |
| preview: | |
| if: github.event_name == 'pull_request' && | |
| github.event.pull_request.head.repo.full_name == github.repository && | |
| vars.STAGING_APP_ID != '' | |
| runs-on: ubuntu-latest | |
| needs: [build] | |
| steps: | |
| - name: Mint GitHub App token | |
| id: app-token | |
| uses: actions/create-github-app-token@v3 | |
| with: | |
| client-id: ${{ vars.STAGING_APP_ID }} | |
| private-key: ${{ secrets.STAGING_APP_PRIVATE_KEY }} | |
| owner: Interlisp | |
| repositories: | | |
| Interlisp.staging | |
| - name: Trigger staging preview | |
| uses: benc-uk/workflow-dispatch@v1 | |
| with: | |
| workflow: deploy-preview.yml | |
| repo: Interlisp/Interlisp.staging | |
| ref: main | |
| token: ${{ steps.app-token.outputs.token }} | |
| inputs: '{ | |
| "pr_number": "${{ github.event.pull_request.number }}", | |
| "pr_sha": "${{ github.event.pull_request.head.sha }}", | |
| "hugo_version": "${{ env.HUGO_VERSION }}" | |
| }' | |
| # ---------------------------------------------------------------------------- | |
| # Deploy the built site to GitHub Pages. | |
| # Only runs on push or scheduled runs, never on pull requests, and never | |
| # when the build was skipped because the bibliography was already current. | |
| # | |
| deploy: | |
| if: github.event_name != 'pull_request' && needs.build.outputs.skipped != 'true' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: [build] | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |