Skip to content
name: Update Profile
on: [push]
jobs:
update-date:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check if the profile README is up-to-date
run: |
LAST_COMMIT=$(git log -1 --pretty=format:"%s" -- profile/README.md)
echo "Last commit message: '$LAST_COMMIT'"
CI_COMMIT="CI: Update date information in README.md"
if [[ "$LAST_COMMIT" == "$CI_COMMIT" ]]; then
echo "Profile README is up-to-date"
exit 1
fi
- name: Update date in README.md
run: |
# Set the date format
current_date=$(date -u +"%Y-%m-%d")
echo "${current_date}"
tail -n 1 ./profile/README.md
# Use sed to update the date in README.md
sed -i "s/(\*This README was last updated on \*\*)[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}(\*\*)/\*This README was last updated on **${current_date}**/" ./profile/README.md
echo "Updated date in README.md"
tail -n 1 ./profile/README.md
- name: Commit changes
run: |
# Commit changes if any
git config user.name "github-actions"
git config user.email "[email protected]"
git add ./profile/README.md
git commit -m "CI: Update date information in README.md"
git push