Skip to content

Course changelogs

Course changelogs #2

Workflow file for this run

name: Course changelogs
on:
schedule:
# Every Sunday at 00:00 UTC. Scheduled workflows run from the default branch.
- cron: "0 0 * * 0"
workflow_dispatch:
permissions:
contents: write
concurrency:
group: course-changelogs-${{ github.event.repository.default_branch }}
cancel-in-progress: true
jobs:
generate:
name: Generate course changelogs
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- name: Check out complete history
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
ref: ${{ github.event.repository.default_branch }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: "3.13"
- name: Generate and publish weekly recap
shell: bash
env:
REPOSITORY_URL: ${{ github.server_url }}/${{ github.repository }}
TARGET_BRANCH: ${{ github.event.repository.default_branch }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Retry if the default branch advances while this job is running.
for attempt in 1 2 3; do
if [ "$attempt" -gt 1 ]; then
git fetch --no-tags origin \
"+refs/heads/$TARGET_BRANCH:refs/remotes/origin/$TARGET_BRANCH"
git reset --hard "origin/$TARGET_BRANCH"
fi
python latex/tools/generate_changelog.py \
--repository-url "$REPOSITORY_URL"
if [ -z "$(git status --porcelain -- CHANGELOG 1/.gitkeep 2/.gitkeep 3/.gitkeep)" ]; then
echo "Course changelogs are already current."
exit 0
fi
git add -A -- CHANGELOG 1/.gitkeep 2/.gitkeep 3/.gitkeep
git commit -m "docs(changelog): publish weekly course recap [skip ci]"
if git push origin "HEAD:$TARGET_BRANCH"; then
exit 0
fi
echo "The branch advanced; retrying from its latest commit ($attempt/3)."
done
echo "Could not publish the weekly course recap after three attempts." >&2
exit 1