Skip to content

Commit f14dbb3

Browse files
committed
Generate dynamic README
2 parents 92c7dbb + 27a5d9e commit f14dbb3

26 files changed

Lines changed: 4577 additions & 31325 deletions

.github/pull_request_template.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<!--
2-
Never ever change the README.md directly!
3-
4-
Add your contributions to the CONTRIBUTE_README.md!
5-
-->
1+
- [ ] I changed `README_SOURCE.md`, not the generated `README.md`.
2+
- [ ] This pull request contains one suggestion.
3+
- [ ] Java is a primary API, runtime, target or first-class integration.
4+
- [ ] The description explains the distinguishing value and ends with a period.
5+
- [ ] Commercial or restrictive licensing is disclosed where applicable.
Lines changed: 60 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,88 @@
11
name: Update README
22

33
on:
4-
schedule:
5-
# Run once a week on Monday at 00:00 UTC
6-
- cron: "0 0 * * 1"
7-
workflow_dispatch: # Allow manual triggering
4+
pull_request:
5+
paths:
6+
- "README_SOURCE.md"
7+
- "CONTRIBUTING.md"
8+
- ".github/pull_request_template.md"
9+
- ".github/workflows/update-readme.yml"
10+
- "scripts/**"
811
push:
912
branches:
1013
- master
1114
- test
1215
paths:
13-
- "CONTRIBUTE_README.md"
16+
- "README_SOURCE.md"
17+
- ".github/workflows/update-readme.yml"
1418
- "scripts/**"
19+
schedule:
20+
- cron: "0 0 * * 1"
21+
workflow_dispatch:
22+
23+
permissions:
24+
contents: read
25+
26+
concurrency:
27+
group: update-readme-${{ github.ref }}
28+
cancel-in-progress: false
1529

1630
jobs:
17-
update-readme:
31+
validate:
32+
if: github.event_name == 'pull_request'
1833
runs-on: ubuntu-latest
19-
2034
steps:
21-
- name: Checkout repository
22-
uses: actions/checkout@v4
35+
- uses: actions/checkout@v6
36+
- uses: actions/setup-java@v5
2337
with:
24-
fetch-depth: 0 # Fetch all history for git operations
38+
distribution: temurin
39+
java-version: "25"
40+
- name: Validate source and generator
41+
run: |
42+
java scripts/generate_readme.java self-test
43+
java scripts/generate_readme.java check README_SOURCE.md
2544
26-
- name: Set up Java
27-
uses: actions/setup-java@v4
45+
update:
46+
if: github.event_name != 'pull_request'
47+
runs-on: ubuntu-latest
48+
permissions:
49+
contents: write
50+
steps:
51+
- uses: actions/checkout@v6
52+
with:
53+
fetch-depth: 0
54+
- uses: actions/setup-java@v5
2855
with:
29-
distribution: "temurin"
56+
distribution: temurin
3057
java-version: "25"
31-
32-
- name: Restore stats cache
58+
- name: Restore statistics cache
59+
uses: actions/cache@v4
60+
with:
61+
path: .cache/github-stats.tsv
62+
key: readme-stats-${{ github.ref_name }}-${{ github.run_id }}
63+
restore-keys: |
64+
readme-stats-${{ github.ref_name }}-
65+
- name: Validate source and generator
3366
run: |
34-
mkdir -p .tmp
35-
# On scheduled runs, refresh all stats by not restoring cache
36-
# On manual/push runs, use cache to avoid unnecessary API calls
37-
if [ "${{ github.event_name }}" == "schedule" ]; then
38-
echo "Scheduled run detected - will fetch fresh data for all repositories"
39-
# Don't restore cache, let script fetch everything fresh
40-
else
41-
# Try to restore stats cache from previous run
42-
if git show HEAD:.tmp/github-stats.txt > .tmp/github-stats.txt 2>/dev/null; then
43-
echo "Restored existing stats cache from previous commit"
44-
else
45-
echo "No existing stats cache found, will fetch all data"
46-
fi
47-
fi
48-
49-
- name: Run README generation workflow
67+
java scripts/generate_readme.java self-test
68+
java scripts/generate_readme.java check README_SOURCE.md
69+
- name: Generate README
5070
env:
5171
PAT: ${{ secrets.PAT }}
5272
run: |
53-
java --enable-preview --source 25 scripts/run_workflow.java
54-
55-
- name: Commit updated README and stats cache
73+
args=()
74+
if [ "${{ github.event_name }}" = "schedule" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
75+
args+=(--refresh-all)
76+
fi
77+
java scripts/generate_readme.java generate README_SOURCE.md README.md .cache/github-stats.tsv "${args[@]}" --branch "$GITHUB_REF_NAME"
78+
- name: Commit README
5679
run: |
5780
git config --local user.email "action@github.com"
5881
git config --local user.name "GitHub Action"
59-
git add -f README.md
60-
# Always commit the stats cache so it persists for next run
61-
git add -f .tmp/github-stats.txt || true
82+
git add README.md
6283
if git diff --staged --quiet; then
63-
echo "No changes to commit"
84+
echo "README is already current"
6485
else
65-
git commit -m "Update README with latest GitHub stats [skip ci]"
86+
git commit -m "Update README with latest GitHub stats"
6687
git push
6788
fi

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.idea/
22
.vscode/
33
.tmp/
4-
.tool-versions
5-
README.md
4+
.cache/

0 commit comments

Comments
 (0)