Skip to content

Commit a89e1bf

Browse files
authored
pull -> push
1 parent 079c70a commit a89e1bf

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

.github/workflows/update-md-date.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ on:
77

88
permissions:
99
contents: write
10+
pull-requests: write
1011

1112
jobs:
1213
update-date:
1314
runs-on: ubuntu-latest
1415

1516
steps:
16-
- name: Checkout repository
17+
- name: Checkout PR branch
1718
uses: actions/checkout@v4
1819
with:
1920
fetch-depth: 0
21+
ref: ${{ github.event.pull_request.head.ref }}
2022

2123
- name: Set up Python
2224
uses: actions/setup-python@v4
@@ -34,8 +36,13 @@ jobs:
3436
- name: Update last modified date in Markdown files
3537
run: python .github/workflows/update_date.py
3638

37-
- name: Commit changes
39+
- name: Pull (merge) remote changes, commit, and push if needed
40+
env:
41+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
3842
run: |
43+
BRANCH="${{ github.event.pull_request.head.ref }}"
44+
git pull origin "$BRANCH" || echo "No merge needed"
3945
git add -A
4046
git commit -m "Update last modified date in Markdown files" || echo "No changes to commit"
41-
git push origin HEAD:${{ github.event.pull_request.head.ref }}
47+
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
48+
git push origin HEAD:"$BRANCH"

0 commit comments

Comments
 (0)