File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments