Skip to content

Commit b89d87f

Browse files
Add workflow to update date in README title
1 parent 46c5762 commit b89d87f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Update Date in README Title
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 6' # This will run the workflow every Saturday at midnight UTC
6+
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab for testing
7+
8+
jobs:
9+
update-readme:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out repository
13+
uses: actions/checkout@v4
14+
15+
- name: Update date in README
16+
run: |
17+
# This command finds the pattern like "[2025 Latest Project]" and replaces it.
18+
# The regular expression looks for:
19+
# \[ - A literal opening square bracket
20+
# .* - Any characters (like a previous date or year)
21+
# Latest Project\] - The literal text "Latest Project]"
22+
# It replaces this with the current date in the format "[d Mon YYYY Latest Project]".
23+
sed -i "s/\[.*Latest Project\]/\[$(date +'%d %b %Y') Latest Project\]/" README.md
24+
25+
- name: Commit and push if changed
26+
run: |
27+
# Check if the README.md file has been modified
28+
if ! git diff --quiet README.md; then
29+
echo "README.md has been updated. Committing changes."
30+
git config --global user.name 'github-actions[bot]'
31+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
32+
git add README.md
33+
git commit -m "docs: Update date in README title"
34+
git push
35+
else
36+
echo "No changes to commit. README is up-to-date."
37+
fi

0 commit comments

Comments
 (0)