-
Notifications
You must be signed in to change notification settings - Fork 1
35 lines (29 loc) · 985 Bytes
/
update-readme.yml
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
name: Update README with Last Update Timestamp
on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set current date and time
id: datetime
run: echo "CURRENT_DATE=$(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> $GITHUB_ENV
- name: Update README.md
run: |
# Check if the line exists and replace it, otherwise add it
if grep -q "Last updated:" README.md; then
sed -i "s|Last updated:.*|Last updated: $CURRENT_DATE|" README.md
else
echo -e "\nLast updated: $CURRENT_DATE" >> README.md
fi
- name: Commit changes
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
git add README.md
git commit -m "Update README with last update timestamp"
git push