|
1 | | -name: "Publish docs" |
| 1 | +name: "Trigger docs builds" |
2 | 2 |
|
3 | 3 | # This workflow's job is dispatching docs-generate-html.yml with the right build-ref(s) |
4 | 4 | # for whatever just happened - it is NOT the only valid way to wire this up, and isn't |
5 | | -# always the right choice. |
| 5 | +# always the right choice. It doesn't publish anything itself - docs-generate-html.yml |
| 6 | +# hands off to the (separate) docs-publish repo for that. |
6 | 7 | # |
7 | | -# Use this (docs-publish.yml -> docs-generate-html.yml) when a single trigger might |
| 8 | +# Use this (docs-trigger-builds.yml -> docs-generate-html.yml) when a single trigger might |
8 | 9 | # legitimately need to build more than one environment - e.g. a manual "rebuild |
9 | 10 | # everything" workflow_dispatch, or a repo where DOCS_DEV_BRANCH == DOCS_PROD_BRANCH (one |
10 | 11 | # branch serving both, so every push to it always means both). |
@@ -104,19 +105,36 @@ jobs: |
104 | 105 | uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 |
105 | 106 | env: |
106 | 107 | BUILDS: ${{ needs.prepare-ref-env.outputs.builds }} |
107 | | - DISPATCH_REF: ${{ github.ref_name }} |
108 | 108 | with: |
109 | 109 | script: | |
110 | 110 | const builds = JSON.parse(process.env.BUILDS) |
| 111 | + const lines = [] |
111 | 112 | for (const build of builds) { |
112 | 113 | await github.rest.actions.createWorkflowDispatch({ |
113 | 114 | owner: context.repo.owner, |
114 | 115 | repo: context.repo.repo, |
115 | 116 | workflow_id: 'docs-generate-html.yml', |
116 | | - ref: process.env.DISPATCH_REF, |
| 117 | + // Dispatch from build.buildRef itself, NOT the branch that triggered |
| 118 | + // this workflow - this run's ref becomes its real head_branch, which is |
| 119 | + // exactly what docs-publish's check-build-branch inspects. Using a |
| 120 | + // single fixed ref for every build here would make every dispatched |
| 121 | + // run's head_branch equal whatever branch triggered THIS workflow, |
| 122 | + // regardless of which environment it's actually building for - so a |
| 123 | + // trigger from any branch other than build.buildRef (e.g. a versioned |
| 124 | + // content branch, or the "other" branch when both are built) would |
| 125 | + // always fail that check downstream, even for an otherwise-legitimate |
| 126 | + // build. |
| 127 | + ref: build.buildRef, |
117 | 128 | inputs: { |
118 | 129 | 'build-ref': build.buildRef, |
119 | 130 | 'publish-env': build.publishEnv, |
120 | 131 | }, |
121 | 132 | }) |
| 133 | + const envNote = build.publishEnv ? ` (publish-env override: \`${build.publishEnv}\`)` : '' |
| 134 | + lines.push(`- \`docs-generate-html.yml\` for build-ref \`${build.buildRef}\`${envNote}`) |
122 | 135 | } |
| 136 | +
|
| 137 | + await core.summary |
| 138 | + .addHeading('Triggered builds') |
| 139 | + .addRaw(lines.join('\n')) |
| 140 | + .write() |
0 commit comments