@@ -57,46 +57,36 @@ 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- # Pre-commit all changes before any branch switching
60+ # Pre-commit changes before any branch switching to avoid overwriting local changes
6161 - name : Pre-commit local changes
6262 run : |
6363 git add "*.md" metrics.json || true
64- git commit -m "Save local changes before branch switching " || echo "No changes to commit"
64+ git commit -m "Auto-commit local changes before branch switch " || echo "No changes to commit"
6565
66- # Commit and push logic for PR events
66+ # Commit and push logic for PR events (merge, not rebase)
6767 - name : Commit and push changes (PR)
6868 if : github.event_name == 'pull_request'
6969 env :
7070 TOKEN : ${{ secrets.GITHUB_TOKEN }}
7171 run : |
7272 git fetch origin
7373 git checkout ${{ github.head_ref }}
74- git pull --rebase origin ${{ github.head_ref }} || echo "No rebase needed"
74+ git pull origin ${{ github.head_ref }} || echo "No merge needed"
7575 git add "*.md" metrics.json
7676 git commit -m "Update visitor count" || echo "No changes to commit"
7777 git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
7878 git push origin HEAD:${{ github.head_ref }}
7979
80- # Commit and push logic for non-PR events (schedule, workflow_dispatch )
80+ # Commit and push logic for non-PR events (merge, not rebase )
8181 - name : Commit and push changes (non-PR)
8282 if : github.event_name != 'pull_request'
8383 env :
8484 TOKEN : ${{ secrets.GITHUB_TOKEN }}
8585 run : |
8686 git fetch origin
8787 git checkout ${{ github.ref_name }} || git checkout -b ${{ github.ref_name }} origin/${{ github.ref_name }}
88- git pull --rebase origin ${{ github.ref_name }} || echo "No rebase needed"
88+ git pull origin ${{ github.ref_name }} || echo "No merge needed"
8989 git add "*.md" metrics.json
9090 git commit -m "Update visitor count" || echo "No changes to commit"
9191 git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
9292 git push origin HEAD:${{ github.ref_name }}
93-
94- - name : Create Pull Request (non-PR)
95- if : github.event_name != 'pull_request'
96- uses : peter-evans/create-pull-request@v6
97- with :
98- token : ${{ secrets.GITHUB_TOKEN }}
99- branch : update-visitor-count
100- title : " Update visitor count"
101- body : " Automated update of visitor count"
102- base : main
0 commit comments