@@ -57,40 +57,32 @@ jobs:
5757 git config --global user.name "github-actions[bot]"
5858 git config --global user.email "github-actions[bot]@users.noreply.github.com"
5959
60- # Commit and push logic for PR events
60+ # Commit and push logic for PR events (merge, not rebase)
6161 - name : Commit and push changes (PR)
6262 if : github.event_name == 'pull_request'
6363 env :
6464 TOKEN : ${{ secrets.GITHUB_TOKEN }}
6565 run : |
6666 git fetch origin
6767 git checkout ${{ github.head_ref }}
68- git add "*.md" metrics.json
68+ git pull origin ${{ github.head_ref }} || echo "No merge needed"
69+ git add "*.md" || true
70+ [ -f metrics.json ] && git add metrics.json || true
6971 git commit -m "Update visitor count" || echo "No changes to commit"
7072 git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
71- git pull --rebase origin ${{ github.head_ref }} || echo "No rebase needed"
7273 git push origin HEAD:${{ github.head_ref }}
7374
74- # Commit and push logic for non-PR events (schedule, workflow_dispatch )
75+ # Commit and push logic for non-PR events (merge, not rebase )
7576 - name : Commit and push changes (non-PR)
7677 if : github.event_name != 'pull_request'
7778 env :
7879 TOKEN : ${{ secrets.GITHUB_TOKEN }}
7980 run : |
8081 git fetch origin
8182 git checkout ${{ github.ref_name }} || git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
82- git add "*.md" metrics.json
83+ git pull origin ${{ github.ref_name }} || echo "No merge needed"
84+ git add "*.md" || true
85+ [ -f metrics.json ] && git add metrics.json || true
8386 git commit -m "Update visitor count" || echo "No changes to commit"
8487 git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
85- git pull --rebase origin ${{ github.ref_name }} || echo "No rebase needed"
8688 git push origin HEAD:${{ github.ref_name }}
87-
88- - name : Create Pull Request (non-PR)
89- if : github.event_name != 'pull_request'
90- uses : peter-evans/create-pull-request@v6
91- with :
92- token : ${{ secrets.GITHUB_TOKEN }}
93- branch : update-visitor-count
94- title : " Update visitor count"
95- body : " Automated update of visitor count"
96- base : main
0 commit comments