Apply Overlays #25
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: Apply Overlays | |
| # This workflow applies HTML overlays (canonical URLs, robots noindex, metadata.js) to | |
| # deployed content and pushes to the postdeploy branches. | |
| # | |
| # In normal operation, the workflow_run trigger fires when release-tag.yml completes. | |
| # Pushes made by release-tag.yml using GITHUB_TOKEN do NOT trigger the push events | |
| # (GitHub prevents this to avoid infinite loops). | |
| on: | |
| workflow_run: | |
| workflows: ["Deploy Tagged Version"] | |
| types: | |
| - completed | |
| push: | |
| branches: | |
| - "deploy" | |
| - "deploy-tutorials" | |
| workflow_dispatch: | |
| jobs: | |
| apply-overlays: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # This allows pushing to the repository | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Configure Git | |
| # These values are recommended at: | |
| # https://github.com/actions/checkout?tab=readme-ov-file#push-a-commit-using-the-built-in-token | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git fetch origin deploy:deploy | |
| git fetch origin postdeploy:postdeploy | |
| git fetch origin deploy-tutorials:deploy-tutorials | |
| git fetch origin postdeploy-tutorials:postdeploy-tutorials | |
| # Run reference overlay if triggered by workflow_run, workflow_dispatch, or push to deploy | |
| - name: Run overlay script | |
| if: github.event_name != 'push' || github.ref == 'refs/heads/deploy' | |
| run: | | |
| echo "Adding overlays to predeploy" | |
| # -B to prevent creation of __pycache__ directory | |
| # which would get committed due to lack of .gitignore | |
| python -B deploy/overlay.py . deploy postdeploy --site-dir reference | |
| - name: Push deploy branch | |
| if: github.event_name != 'push' || github.ref == 'refs/heads/deploy' | |
| run: | | |
| git push origin postdeploy | |
| # Run tutorials overlay if triggered by workflow_run, workflow_dispatch, or push to deploy-tutorials | |
| - name: Run overlay script for tutorials | |
| if: github.event_name != 'push' || github.ref == 'refs/heads/deploy-tutorials' | |
| run: | | |
| echo "Adding overlays to tutorials predeploy" | |
| python -B deploy/overlay.py . deploy-tutorials postdeploy-tutorials --site-dir tutorials | |
| - name: Push tutorials deploy branch | |
| if: github.event_name != 'push' || github.ref == 'refs/heads/deploy-tutorials' | |
| run: | | |
| git push origin postdeploy-tutorials |