Skip to content

Commit e01638c

Browse files
vdusekclaude
andauthored
ci: Fix docs release failing on detached HEAD (#1851)
## Summary `actions/checkout` detaches HEAD when checking out a SHA, which blocks `EndBug/add-and-commit` from pushing the versioned docs commit. Pass `new_branch` so the action pushes to the default branch, and tighten the trigger contract so `ref` is only required for `workflow_call` (for `workflow_dispatch` the default branch is always used). Mirrors apify/apify-client-python#741 and the equivalent fix in apify-sdk-python. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 06f14a4 commit e01638c

3 files changed

Lines changed: 10 additions & 37 deletions

File tree

.github/workflows/manual_release_docs.yaml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@ name: Release docs
33
on:
44
# Runs when manually triggered from the GitHub UI.
55
workflow_dispatch:
6-
inputs:
7-
ref:
8-
description: Git ref to checkout (branch, tag, or SHA). Defaults to the default branch.
9-
required: false
10-
type: string
11-
default: ""
126

137
# Runs when invoked by another workflow.
148
workflow_call:
159
inputs:
1610
ref:
17-
description: Git ref to checkout (branch, tag, or SHA)
11+
description: Git ref to checkout.
1812
required: true
1913
type: string
2014

@@ -37,20 +31,11 @@ jobs:
3731
runs-on: ubuntu-latest
3832

3933
steps:
40-
- name: Determine checkout ref
41-
id: resolve_ref
42-
env:
43-
INPUT_REF: ${{ inputs.ref }}
44-
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
45-
run: |
46-
REF="${INPUT_REF:-$DEFAULT_BRANCH}"
47-
echo "ref=$REF" >> "$GITHUB_OUTPUT"
48-
4934
- name: Checkout repository
5035
uses: actions/checkout@v6
5136
with:
5237
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
53-
ref: ${{ steps.resolve_ref.outputs.ref }}
38+
ref: ${{ inputs.ref || github.event.repository.default_branch }}
5439

5540
- name: Set up Node
5641
uses: actions/setup-node@v6

.github/workflows/manual_release_stable.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
is_prerelease: ""
9898
version_number: ${{ needs.release_prepare.outputs.version_number }}
9999
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
100-
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
100+
# Publish the package to PyPI using PyPA official GitHub action with OIDC authentication.
101101
- name: Publish package to PyPI
102102
uses: pypa/gh-action-pypi-publish@release/v1
103103

@@ -111,6 +111,7 @@ jobs:
111111
contents: write
112112
uses: ./.github/workflows/manual_version_docs.yaml
113113
with:
114+
# Commit the version docs changes on top of the changelog commit.
114115
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
115116
secrets: inherit
116117

@@ -123,6 +124,6 @@ jobs:
123124
id-token: write
124125
uses: ./.github/workflows/manual_release_docs.yaml
125126
with:
126-
# Use the version_docs commit to include both changelog and versioned docs.
127+
# Use the commit with the version docs changes as the source for the release docs.
127128
ref: ${{ needs.version_docs.outputs.version_docs_commitish }}
128129
secrets: inherit

.github/workflows/manual_version_docs.yaml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,17 @@ name: Version docs
33
on:
44
# Runs when manually triggered from the GitHub UI.
55
workflow_dispatch:
6-
inputs:
7-
ref:
8-
description: Git ref to checkout (branch, tag, or SHA). Defaults to the default branch.
9-
required: false
10-
type: string
11-
default: ""
126

137
# Runs when invoked by another workflow.
148
workflow_call:
159
inputs:
1610
ref:
17-
description: Git ref to checkout (branch, tag, or SHA)
11+
description: Git ref to checkout.
1812
required: true
1913
type: string
2014
outputs:
2115
version_docs_commitish:
22-
description: The commit SHA of the versioned docs commit
16+
description: The commit SHA of the versioned docs commit.
2317
value: ${{ jobs.version_docs.outputs.version_docs_commitish }}
2418

2519
concurrency:
@@ -43,20 +37,11 @@ jobs:
4337
contents: write
4438

4539
steps:
46-
- name: Determine checkout ref
47-
id: resolve_ref
48-
env:
49-
INPUT_REF: ${{ inputs.ref }}
50-
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
51-
run: |
52-
REF="${INPUT_REF:-$DEFAULT_BRANCH}"
53-
echo "ref=$REF" >> "$GITHUB_OUTPUT"
54-
5540
- name: Checkout repository
5641
uses: actions/checkout@v6
5742
with:
5843
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
59-
ref: ${{ steps.resolve_ref.outputs.ref }}
44+
ref: ${{ inputs.ref || github.event.repository.default_branch }}
6045

6146
- name: Set up Node
6247
uses: actions/setup-node@v6
@@ -123,6 +108,8 @@ jobs:
123108
add: website/versioned_docs website/versioned_sidebars website/versions.json
124109
message: "docs: Version docs for v${{ steps.snapshot.outputs.version }} [skip ci]"
125110
default_author: github_actions
111+
# `actions/checkout` detaches HEAD on SHA refs; EndBug needs a branch to push.
112+
new_branch: ${{ github.event.repository.default_branch }}
126113

127114
- name: Resolve output commitish
128115
id: resolve_commitish

0 commit comments

Comments
 (0)