day 19 #50
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 ⭐ | |
on: | |
schedule: | |
- cron: "0 11 * 12 *" | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
update-readme: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Check year for cron | |
if: github.event_name == 'schedule' | |
run: | | |
current_year=$(date +'%Y') | |
if [ "$current_year" -ne "2024" ]; then | |
echo "No longer 2024, delete this action's schedule." | |
exit 1 | |
fi | |
- name: Check commit message for push | |
id: check_commit_message | |
if: github.event_name == 'push' | |
continue-on-error: true | |
run: | | |
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
if ! [[ "$COMMIT_MESSAGE" =~ ^day\ [0-9]{2}$ ]]; then | |
echo "Commit message does not match solution pattern" | |
exit 1 | |
fi | |
- name: Update README progress | |
id: update_readme_progress | |
if: steps.check_commit_message.outcome == 'success' || github.event_name != 'push' | |
uses: k2bd/advent-readme-stars@v1 | |
with: | |
userId: 4388690 | |
year: 2024 | |
sessionCookie: ${{ secrets.AOC_SESSION }} | |
- name: Update README badge | |
id: update_readme_badge | |
if: steps.check_commit_message.outcome == 'success' || github.event_name != 'push' | |
uses: joblo2213/aoc-badges-action@v3 | |
with: | |
userId: 4388690 | |
year: 2024 | |
session: ${{ secrets.AOC_SESSION }} | |
- name: Commit changes | |
if: steps.update_readme_progress.conclusion == 'success' && steps.update_readme_badge.conclusion == 'success' | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: auto-update README stars |