Skip to content

Commit 484dc99

Browse files
authored
fix: handling doc creation gracefully
- if there's nothing to commit, then no need to push to origin - also make sure to switch to the correct branch
1 parent fc83b1c commit 484dc99

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

.github/workflows/add-docs-to-release.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
with:
2626
node-version: 20.x
2727

28+
- name: Make sure to be on PR branch
29+
run: git checkout ${GITHUB_HEAD_REF}
30+
2831
- name: Install packages
2932
run: pnpm install
3033

@@ -34,10 +37,22 @@ jobs:
3437
- name: Build Docs
3538
run: pnpm build:docs
3639

37-
- name: Commit and push docs
40+
- name: Commit docs
41+
id: commit_docs
42+
run: |
43+
git add docs
44+
if git diff --cached --quiet; then
45+
echo "No changes to commit."
46+
echo "commit=false" >> $GITHUB_OUTPUT
47+
else
48+
git commit -m "chore: update docs [skip ci]"
49+
echo "commit=true" >> $GITHUB_OUTPUT
50+
fi
51+
52+
- name: Push docs (only if commit was made)
53+
if: steps.commit_docs.outputs.commit == 'true'
3854
run: |
3955
git config user.name "github-actions[bot]"
4056
git config user.email "github-actions[bot]@users.noreply.github.com"
41-
git add docs
42-
git commit -m "chore: update docs [skip ci]" || echo "No changes to commit"
4357
git push origin HEAD:${GITHUB_HEAD_REF} --force-with-lease
58+

0 commit comments

Comments
 (0)