-
Notifications
You must be signed in to change notification settings - Fork 3
48 lines (39 loc) · 1.36 KB
/
update-md-date.yml
File metadata and controls
48 lines (39 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Update Last Modified Date
on:
pull_request:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
update-date:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: pip install python-dateutil
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Update last modified date in Markdown files
run: python .github/workflows/update_date.py
- name: Pull (merge) remote changes, commit, and push if needed
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BRANCH="${{ github.event.pull_request.head.ref }}"
git pull origin "$BRANCH" || echo "No merge needed"
git add -A
git commit -m "Update last modified date in Markdown files" || echo "No changes to commit"
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
git push origin HEAD:"$BRANCH"