Skip to content

Commit 6c3b84d

Browse files
vdusekclaude
andauthored
ci: Fix docs release failing on detached HEAD (#741)
## Summary The `doc_release_post_publish` job in `on_master.yaml` invokes `manual_release_docs.yaml` with a commit SHA as `ref`, so `actions/checkout` leaves the repo in a detached HEAD state. The hand-rolled `Commit the updated package.json and lockfile` step then runs `git push`, which fails with `fatal: You are not currently on a branch.` (see [failing run](https://github.com/apify/apify-client-python/actions/runs/24564853529/job/71822812783)). The push was also invoked unconditionally even when there was nothing to commit. ## Fix - Replace the hand-rolled git block with `EndBug/add-and-commit@v10` (matching `manual_version_docs.yaml`). - Set `new_branch: ${{ github.event.repository.default_branch }}` so the action creates/checks out a local default branch before committing. This is required because EndBug does not handle detached HEAD by itself — its default push is `git push origin --set-upstream` (no refspec), which fails the same way. - Apply the same `new_branch` fix to `manual_version_docs.yaml`, which has the identical latent bug (introduced in #728 but not yet exercised by a stable release). --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 76e4de4 commit 6c3b84d

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

@@ -34,20 +28,11 @@ jobs:
3428
runs-on: ubuntu-latest
3529

3630
steps:
37-
- name: Determine checkout ref
38-
id: resolve_ref
39-
env:
40-
INPUT_REF: ${{ inputs.ref }}
41-
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
42-
run: |
43-
REF="${INPUT_REF:-$DEFAULT_BRANCH}"
44-
echo "ref=$REF" >> "$GITHUB_OUTPUT"
45-
4631
- name: Checkout repository
4732
uses: actions/checkout@v6
4833
with:
4934
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
50-
ref: ${{ steps.resolve_ref.outputs.ref }}
35+
ref: ${{ inputs.ref || github.event.repository.default_branch }}
5136

5237
- name: Set up Node
5338
uses: actions/setup-node@v6
@@ -71,13 +56,13 @@ jobs:
7156
run: uv run poe update-docs-theme
7257

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

8267
- name: Build docs
8368
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,6 +122,6 @@ 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

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