Update README with Last Update Timestamp #549
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |