@@ -72,6 +72,7 @@ Add a new workflow looking like this:
7272# .github/workflows/publish.yml
7373name: "Publish to GitHub Pages"
7474on:
75+ delete:
7576 workflow_run:
7677 workflows:
7778 # This must match your build workflow's name
@@ -82,6 +83,9 @@ permissions:
8283 contents: read
8384 pages: write
8485 id-token: write
86+ concurrency:
87+ group: ${{ github.workflow }}
88+ cancel-in-progress: true
8589publish:
8690 name: Publish all branches to GitHub Pages
8791 runs-on: ubuntu-latest
@@ -96,26 +100,26 @@ publish:
96100The important elements are :
97101
981021. The `workflow_run` trigger : this causes the publish workflow to run whenever
99- any of the input artifacts are updated.
103+ any of the input artifacts are updated. (The `delete` trigger causes the
104+ workflow to run when a branch is deleted.)
105+
1001062. The `permissions` section : this workflow must be allowed to write to GitHub Pages.
107+
1011083. The `workflow_name` and `artifact_name` parameters to this action : these are how the
102109 action finds the artifacts to amalgamate and publish.
103110
104- You may also want to specify the following to reduce redundant builds :
105-
106- ` ` ` yaml
107- # Cancel any ongoing previous run if the job is re-triggered
108- concurrency:
109- group: ${{ github.workflow }}
110- cancel-in-progress: true
111- ` ` `
111+ 4. The `concurrency` rule reduces duplicate runs when the workflow is triggered
112+ by several events in quick succession; in particular, merging a pull request
113+ and deleting the source branch will cause the workflow to be triggered once
114+ by the branch deletion and again by the `main` branch being built after the
115+ merge.
112116
113117# # Limitations
114118
115- Currently, any branch for which an artifact is found will be included in the
116- amalgamated site. This means :
117-
118- - Branches that have been merged into `main` will be included until their build
119- artifacts expire and something else triggers a rebuild of the site;
120- - Unmerged branches whose artifacts have expired will not be included once the
121- site is rebuilt .
119+ Any branch for which an artifact is found will be included in the amalgamated
120+ site, unless there is a closed pull request for the branch. In particular this
121+ means that if you have a long-lived branch which is not regularly built, at some
122+ point its build artifact will expire and will not be included in the amalgamated
123+ site. Instead, the branches index will show the date on which it expired.
124+ Manually triggering the build workflow on that branch, or pushing a new commit
125+ to trigger a build, will restore it .
0 commit comments