Skip to content

Commit db01ddc

Browse files
authored
ci: gate manual docs releases on the built commit (#2480)
The `Wait for checks` step in `manual_release_docs.yaml` waited for checks on `github.sha`, but the job builds and deploys the docs from `inputs.ref`. A manual run with `ref` set to another commit was gated on the wrong commit. - The gate now runs after the checkout and waits for checks on the commit that was checked out. - A manual run also checks that this commit is on `master` or a `release-v*` branch. - The release workflows that call this workflow skip both steps through the new `skip_checks` input. They have their own gate. `github.event_name` in a called workflow is the caller's event, so the old `workflow_dispatch` condition also ran the gate inside dispatched releases. *✍️ Drafted by Claude Code*
1 parent e8cf24f commit db01ddc

1 file changed

Lines changed: 34 additions & 9 deletions

File tree

‎.github/workflows/manual_release_docs.yaml‎

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ on:
1818
required: false
1919
type: string
2020
default: ""
21+
skip_checks:
22+
description: Skip the release branch and `Checks` gate for the built commit. The calling workflows run their own gate.
23+
required: false
24+
type: boolean
25+
default: true
2126

2227
permissions:
2328
contents: read
@@ -35,21 +40,41 @@ jobs:
3540
runs-on: ubuntu-latest
3641

3742
steps:
38-
# Gate manual dispatches on the `Checks` workflow already succeeding on this commit (run by `on_master.yaml`);
39-
# skipped when called from another workflow.
40-
- name: Wait for checks
41-
if: github.event_name == 'workflow_dispatch'
42-
uses: apify/actions/wait-for-checks@v1.6.2
43-
with:
44-
ref: ${{ github.sha }}
45-
check-regexp: ^Checks
46-
4743
- name: Checkout repository
4844
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
4945
with:
5046
ref: ${{ inputs.ref }}
5147
persist-credentials: false
5248

49+
- name: Record the built commit
50+
id: sha
51+
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
52+
53+
# A manual dispatch builds only a commit that is on a release branch and passed the `Checks` workflow (run by
54+
# `on_master.yaml`). Calling workflows skip both steps through `skip_checks`.
55+
- name: Check that the commit is on a release branch
56+
if: ${{ !inputs.skip_checks }}
57+
env:
58+
GH_TOKEN: ${{ github.token }}
59+
SHA: ${{ steps.sha.outputs.sha }}
60+
run: |
61+
branches=$(gh api --paginate "repos/$GITHUB_REPOSITORY/branches" --jq '.[].name' | grep -E '^(master|release-v.+)$')
62+
for branch in $branches; do
63+
status=$(gh api "repos/$GITHUB_REPOSITORY/compare/$branch...$SHA" --jq .status || true)
64+
if [[ "$status" == "identical" || "$status" == "behind" ]]; then
65+
exit 0
66+
fi
67+
done
68+
echo "::error::$SHA is not on a release branch"
69+
exit 1
70+
71+
- name: Wait for checks
72+
if: ${{ !inputs.skip_checks }}
73+
uses: apify/actions/wait-for-checks@v1.6.2
74+
with:
75+
ref: ${{ steps.sha.outputs.sha }}
76+
check-regexp: ^Checks
77+
5378
- name: Set up Node
5479
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
5580
with:

0 commit comments

Comments
 (0)