Skip to content

Commit 63a7e30

Browse files
authored
Merge pull request awesome-mlss#305 from awesome-mlss/2026readme
Automate Readme rollovers and updates
2 parents 2f1ba2b + f58ce40 commit 63a7e30

35 files changed

Lines changed: 3449 additions & 291 deletions

.github/CODEOWNERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# YAML data changes need maintainer approval.
2+
site/_data/*.yml @sshkhr @gmberton @smsnobin77
3+
4+
# Workflow and script changes need maintainer approval.
5+
.github/workflows/* @sshkhr @gmberton @smsnobin77
6+
scripts/* @sshkhr @gmberton @smsnobin77
7+
8+
# README.md is auto-managed — no code-owner review required, so the bot PR can merge.
Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,40 @@
1-
name: Update README (pull_request)
1+
name: README preview (PR)
22

33
on:
4-
pull_request_target:
4+
pull_request:
55
paths:
66
- 'site/_data/summerschools.yml'
7-
workflow_dispatch:
87

98
permissions:
10-
pull-requests: write
119
contents: read
12-
10+
1311
jobs:
14-
update-readme-pr:
12+
render-preview:
1513
runs-on: ubuntu-latest
1614
steps:
17-
- name: Check out repository
18-
uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1916
with:
20-
ref: ${{ github.event.pull_request.head.ref }}
21-
repository: ${{ github.event.pull_request.head.repo.full_name }}
2217
fetch-depth: 0
23-
24-
- name: Set up Python
25-
uses: actions/setup-python@v4
18+
19+
- name: Fetch master
20+
run: git fetch origin master:master
21+
22+
- uses: actions/setup-python@v5
2623
with:
27-
python-version: '3.9'
24+
python-version: '3.11'
2825

29-
- name: Install dependencies
30-
run: |
31-
pip install pyyaml python-dateutil
26+
- run: pip install pyyaml python-dateutil ruamel.yaml
3227

33-
- name: Update README locally (no commit)
34-
id: update_readme
35-
run: |
36-
python scripts/update_readme.py
37-
git diff README.md > diff.txt
28+
- name: Render preview
29+
run: python scripts/pr_preview.py --output preview.md
3830

39-
# Expose the diff as an output
40-
echo "diff<<EOF" >> $GITHUB_OUTPUT
41-
cat diff.txt | sed 's/%/%25/g; s/\n/%0A/g; s/\r/%0D/g' >> $GITHUB_OUTPUT
42-
echo "EOF" >> $GITHUB_OUTPUT
31+
- name: Save PR number
32+
run: echo "${{ github.event.pull_request.number }}" > pr-number.txt
4333

44-
- name: Comment on PR with diff
45-
uses: actions/github-script@v6
34+
- name: Upload artifact
35+
uses: actions/upload-artifact@v4
4636
with:
47-
diff: ${{ steps.update_readme.outputs.diff }}
48-
script: |
49-
const diff = core.getInput('diff');
50-
if (!diff.trim()) {
51-
core.info("No changes in README.md.");
52-
return;
53-
}
54-
await github.rest.issues.createComment({
55-
owner: context.repo.owner,
56-
repo: context.repo.repo,
57-
issue_number: context.issue.number,
58-
body: `**Proposed changes in README.md**\n\`\`\`diff\n${diff}\n\`\`\``
59-
});
60-
env:
61-
diff: ${{ steps.update_readme.outputs.diff }}
37+
name: readme-preview
38+
path: |
39+
preview.md
40+
pr-number.txt
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Post README preview comment
2+
3+
on:
4+
workflow_run:
5+
workflows: ['README preview (PR)']
6+
types: [completed]
7+
8+
permissions:
9+
pull-requests: write
10+
11+
jobs:
12+
post-comment:
13+
runs-on: ubuntu-latest
14+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
15+
steps:
16+
- name: Download preview artifact
17+
uses: actions/download-artifact@v4
18+
with:
19+
name: readme-preview
20+
run-id: ${{ github.event.workflow_run.id }}
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
22+
path: ./preview
23+
24+
- name: Read PR number
25+
id: pr
26+
run: |
27+
number=$(cat ./preview/pr-number.txt)
28+
echo "number=$number" >> "$GITHUB_OUTPUT"
29+
30+
- name: Read preview body
31+
id: body
32+
run: |
33+
{
34+
echo 'body<<PREVIEW_EOF'
35+
cat ./preview/preview.md
36+
echo 'PREVIEW_EOF'
37+
} >> "$GITHUB_OUTPUT"
38+
39+
- name: Find existing preview comment
40+
uses: peter-evans/find-comment@v3
41+
id: find
42+
with:
43+
issue-number: ${{ steps.pr.outputs.number }}
44+
body-includes: '<!-- readme-preview-bot -->'
45+
46+
- name: Create or update comment
47+
uses: peter-evans/create-or-update-comment@v4
48+
with:
49+
issue-number: ${{ steps.pr.outputs.number }}
50+
comment-id: ${{ steps.find.outputs.comment-id }}
51+
body: ${{ steps.body.outputs.body }}
52+
edit-mode: replace

.github/workflows/update-readme-on-push.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Update README (auto)
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 * * *' # 06:00 UTC daily
6+
push:
7+
branches: [master]
8+
paths:
9+
- 'site/_data/summerschools.yml'
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
jobs:
17+
update-readme:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
token: ${{ secrets.BOT_PR_TOKEN }}
23+
fetch-depth: 0
24+
25+
- uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.11'
28+
29+
- run: pip install pyyaml python-dateutil ruamel.yaml
30+
31+
- name: Render README
32+
run: python scripts/update_readme.py
33+
34+
- name: Detect changes
35+
id: diff
36+
run: |
37+
if git diff --quiet README.md; then
38+
echo "changed=false" >> "$GITHUB_OUTPUT"
39+
else
40+
echo "changed=true" >> "$GITHUB_OUTPUT"
41+
fi
42+
43+
- name: Create or update PR
44+
if: steps.diff.outputs.changed == 'true'
45+
id: cpr
46+
uses: peter-evans/create-pull-request@v7
47+
with:
48+
token: ${{ secrets.BOT_PR_TOKEN }}
49+
branch: bot/readme-update
50+
base: master
51+
title: "chore: auto-update README (${{ github.run_started_at }})"
52+
commit-message: "chore: auto-update README"
53+
body: |
54+
Automated README refresh.
55+
56+
This PR is kept in sync by the `update-readme` workflow and auto-merges when checks pass.
57+
add-paths: README.md
58+
delete-branch: true
59+
60+
- name: Enable auto-merge
61+
if: steps.cpr.outputs.pull-request-number
62+
run: gh pr merge --auto --squash "${{ steps.cpr.outputs.pull-request-number }}"
63+
env:
64+
GH_TOKEN: ${{ secrets.BOT_PR_TOKEN }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: validate-readme
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
validate:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
19+
- run: pip install pyyaml python-dateutil ruamel.yaml
20+
21+
- name: Validate YAML schema + renderer
22+
run: python scripts/validate_readme.py

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
**/.DS_Store
2-
site/_site/*
2+
site/_site/*
3+
docs/*
4+
CLAUDE.local.md
5+
**/__pycache__/
6+
.pytest_cache/

0 commit comments

Comments
 (0)