Skip to content

Commit bae7950

Browse files
Timna BrownTimna Brown
authored andcommitted
fix: stash generated files before pull in visitor counter workflow
Visitor counter script modifies tracked files before the branch checkout/pull, causing 'changes would be overwritten' errors and leaving the branch behind remote. Stash before fetch/pull/checkout and pop afterwards to ensure clean merge before push.
1 parent 1356ff7 commit bae7950

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

.github/workflows/use-visitor-counter.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ jobs:
6363
env:
6464
TOKEN: ${{ secrets.GITHUB_TOKEN }}
6565
run: |
66+
git stash --include-untracked
6667
git fetch origin
6768
git checkout ${{ github.head_ref }}
6869
git pull origin ${{ github.head_ref }} || echo "No merge needed"
70+
git stash pop || echo "Nothing stashed"
6971
git add -A
7072
git commit -m "Update visitor count" || echo "No changes to commit"
7173
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
@@ -77,9 +79,11 @@ jobs:
7779
env:
7880
TOKEN: ${{ secrets.GITHUB_TOKEN }}
7981
run: |
82+
git stash --include-untracked
8083
git fetch origin
8184
git checkout ${{ github.ref_name }} || git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
8285
git pull origin ${{ github.ref_name }} || echo "No merge needed"
86+
git stash pop || echo "Nothing stashed"
8387
git add -A
8488
git commit -m "Update visitor count" || echo "No changes to commit"
8589
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}

0 commit comments

Comments
 (0)