Skip to content

Commit 16bf07d

Browse files
vdusekclaude
andauthored
ci: Fix docs release failing on detached HEAD (#866)
## Summary Same fix as apify/apify-client-python#741 — the SDK workflows have the identical bug. When `manual_release_docs.yaml` is invoked with a commit SHA as `ref` (from `doc_release_post_publish` in `on_master.yaml` or from `manual_release_stable.yaml`), `actions/checkout` leaves the repo in detached HEAD state and the hand-rolled `Commit the updated package.json and lockfile` step's `git push` fails with `fatal: You are not currently on a branch.` The same latent bug exists in `manual_version_docs.yaml`'s `EndBug/add-and-commit` step (no `new_branch` set). Neither has fired yet because no `feat`/`fix`/`perf`/`refactor`/`style` commit has landed on master since the reusable-workflow extraction merged. ## Fix - Replace the hand-rolled git block in `manual_release_docs.yaml` with `EndBug/add-and-commit@v10`. - Set `new_branch: ${{ github.event.repository.default_branch }}` in both workflows — EndBug does not handle detached HEAD by itself (its default push is `git push origin --set-upstream` with no refspec, which fails the same way). Setting `new_branch` makes it create/checkout a local default branch at current HEAD before committing. --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 87da1c2 commit 16bf07d

3 files changed

Lines changed: 17 additions & 44 deletions

File tree

.github/workflows/manual_release_docs.yaml

Lines changed: 9 additions & 24 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
@@ -74,13 +59,13 @@ jobs:
7459
run: uv run poe update-docs-theme
7560

7661
- name: Commit the updated package.json and lockfile
77-
run: |
78-
git config user.name 'GitHub Actions'
79-
git config user.email 'github-actions[bot]@users.noreply.github.com'
80-
git add website/package.json
81-
git add website/yarn.lock
82-
git diff-index --quiet HEAD || git commit -m 'chore: Automatic docs theme update [skip ci]' || true
83-
git push
62+
uses: EndBug/add-and-commit@v10
63+
with:
64+
add: website/package.json website/yarn.lock
65+
message: "chore: Automatic docs theme update [skip ci]"
66+
default_author: github_actions
67+
# `actions/checkout` detaches HEAD on SHA refs; EndBug needs a branch to push.
68+
new_branch: ${{ github.event.repository.default_branch }}
8469

8570
- name: Build docs
8671
run: uv run poe build-docs

.github/workflows/manual_release_stable.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ jobs:
9898
version_number: ${{ needs.release_prepare.outputs.version_number }}
9999
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
100100

101-
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
101+
# Publish the package to PyPI using PyPA official GitHub action with OIDC authentication.
102102
- name: Publish package to PyPI
103103
uses: pypa/gh-action-pypi-publish@release/v1
104104

@@ -109,6 +109,7 @@ jobs:
109109
contents: write
110110
uses: ./.github/workflows/manual_version_docs.yaml
111111
with:
112+
# Commit the version docs changes on top of the changelog commit.
112113
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
113114
secrets: inherit
114115

@@ -121,7 +122,7 @@ jobs:
121122
id-token: write
122123
uses: ./.github/workflows/manual_release_docs.yaml
123124
with:
124-
# Use the version_docs commit to include both changelog and versioned docs.
125+
# Commit the docs release changes on top of the version docs commit.
125126
ref: ${{ needs.version_docs.outputs.version_docs_commitish }}
126127
secrets: inherit
127128

.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)