Skip to content

Commit 6c39051

Browse files
committed
ci: enhance GitHub Actions workflow to handle commits based on event type
1 parent da95614 commit 6c39051

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

.github/workflows/build-and-commit.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: actions/checkout@v4
2121
with:
2222
fetch-depth: 0 # Fetch all history for proper versioning
23-
ref: ${{ github.ref }}
23+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
2424

2525
- name: Setup Node.js
2626
uses: actions/setup-node@v4
@@ -42,4 +42,15 @@ jobs:
4242
- name: Commit build results
4343
run: |
4444
git add build/ -f
45-
git diff --quiet && git diff --staged --quiet || (git commit -m "chore: update build files [skip ci]" && git push origin HEAD:${{ github.ref_name }})
45+
if git diff --quiet && git diff --staged --quiet; then
46+
echo "No changes to commit"
47+
exit 0
48+
fi
49+
50+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
51+
git commit -m "chore: update build files [skip ci]"
52+
git push origin HEAD:refs/heads/${{ github.head_ref }}
53+
else
54+
git commit -m "chore: update build files [skip ci]"
55+
git push origin HEAD:refs/heads/${{ github.ref_name }}
56+
fi

0 commit comments

Comments
 (0)