Skip to content

Commit 6eaf147

Browse files
authored
Rename docs-publish.yml, add trigger summary, set ref for triggered build (#127)
1 parent 022f3be commit 6eaf147

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

.github/workflows/docs-generate-html.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ permissions:
66

77
# Builds, verifies, and publishes docs for ONE environment, as a run entirely independent
88
# of any other environment's run. Triggered (via the API, not a workflow_call) by
9-
# docs-publish.yml, once per environment that applies to a given push (dev, prod, or both) -
9+
# docs-trigger-builds.yml, once per environment that applies to a given push (dev, prod, or both) -
1010
# so if dev's run fails, prod's run is completely unaffected, and vice versa.
1111
on:
1212
workflow_dispatch:
Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
name: "Publish docs"
1+
name: "Trigger docs builds"
22

33
# This workflow's job is dispatching docs-generate-html.yml with the right build-ref(s)
44
# 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.
67
#
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
89
# legitimately need to build more than one environment - e.g. a manual "rebuild
910
# everything" workflow_dispatch, or a repo where DOCS_DEV_BRANCH == DOCS_PROD_BRANCH (one
1011
# branch serving both, so every push to it always means both).
@@ -104,19 +105,36 @@ jobs:
104105
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
105106
env:
106107
BUILDS: ${{ needs.prepare-ref-env.outputs.builds }}
107-
DISPATCH_REF: ${{ github.ref_name }}
108108
with:
109109
script: |
110110
const builds = JSON.parse(process.env.BUILDS)
111+
const lines = []
111112
for (const build of builds) {
112113
await github.rest.actions.createWorkflowDispatch({
113114
owner: context.repo.owner,
114115
repo: context.repo.repo,
115116
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,
117128
inputs: {
118129
'build-ref': build.buildRef,
119130
'publish-env': build.publishEnv,
120131
},
121132
})
133+
const envNote = build.publishEnv ? ` (publish-env override: \`${build.publishEnv}\`)` : ''
134+
lines.push(`- \`docs-generate-html.yml\` for build-ref \`${build.buildRef}\`${envNote}`)
122135
}
136+
137+
await core.summary
138+
.addHeading('Triggered builds')
139+
.addRaw(lines.join('\n'))
140+
.write()

0 commit comments

Comments
 (0)