Skip to content

Commit 4b6ecd5

Browse files
Copilotbarjin
andauthored
chore(ci): fix brittle docs-theme publish workflow (#2303)
Reads the `apify-docs-theme` version from `npm` to prevent TOCTOU race when reading from the local git worktree. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: barjin <61918049+barjin@users.noreply.github.com>
1 parent 4c88d25 commit 4b6ecd5

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

.github/workflows/publish-to-npm.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
- master
77
workflow_dispatch:
88

9+
concurrency:
10+
group: publish-theme
11+
cancel-in-progress: false
12+
913
permissions:
1014
id-token: write
1115
contents: write
@@ -69,7 +73,10 @@ jobs:
6973
- name: Bump the theme version
7074
run: |
7175
cd "$GITHUB_WORKSPACE/apify-docs-theme"
72-
npm version patch --legacy-peer-deps
76+
PACKAGE_NAME=$(jq -r .name package.json)
77+
LATEST_VERSION=$(npm show "$PACKAGE_NAME" version 2>/dev/null || jq -r .version package.json)
78+
npm pkg set "version=$LATEST_VERSION"
79+
npm version patch --no-git-tag-version
7380
7481
- name: Deploy theme to npm
7582
run: |
@@ -95,13 +102,13 @@ jobs:
95102
npm show "$PACKAGE_NAME@$PACKAGE_VER" # fails if the package is not available, succeeds if it is
96103
97104
- name: Commit the new theme version
98-
uses: stefanzweifel/git-auto-commit-action@v7
105+
continue-on-error: true
106+
uses: EndBug/add-and-commit@v9
99107
with:
100-
commit_message: 'chore: publish new version of @apify/docs-theme [skip ci]'
101-
file_pattern: 'apify-docs-theme/package*.json'
102-
commit_user_name: Apify Bot
103-
commit_user_email: my-github-actions-bot@example.org
104-
commit_author: Apify Bot <apify@apify.com>
108+
add: 'apify-docs-theme/package*.json'
109+
author_name: github-actions[bot]
110+
author_email: 41898282+github-actions[bot]@users.noreply.github.com
111+
message: 'chore: publish new version of @apify/docs-theme [skip ci]'
105112

106113
rebuild-docs:
107114
needs: publish

0 commit comments

Comments
 (0)