Generate dynamic README #59
This file contains hidden or 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: | |
| pull_request: | |
| paths: | |
| - "README_SOURCE.md" | |
| - "CONTRIBUTING.md" | |
| - ".github/pull_request_template.md" | |
| - ".github/workflows/update-readme.yml" | |
| - "scripts/**" | |
| push: | |
| branches: | |
| - master | |
| - test | |
| paths: | |
| - "README_SOURCE.md" | |
| - ".github/workflows/update-readme.yml" | |
| - "scripts/**" | |
| schedule: | |
| - cron: "0 0 * * 1" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: update-readme-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| validate: | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: "25" | |
| - name: Validate source and generator | |
| run: | | |
| java scripts/generate_readme.java self-test | |
| java scripts/generate_readme.java check README_SOURCE.md | |
| update: | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: "25" | |
| - name: Restore statistics cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: .cache/github-stats.tsv | |
| key: readme-stats-${{ github.ref_name }}-${{ github.run_id }} | |
| restore-keys: | | |
| readme-stats-${{ github.ref_name }}- | |
| - name: Validate source and generator | |
| run: | | |
| java scripts/generate_readme.java self-test | |
| java scripts/generate_readme.java check README_SOURCE.md | |
| - name: Generate README | |
| env: | |
| PAT: ${{ secrets.PAT }} | |
| run: | | |
| args=() | |
| if [ "${{ github.event_name }}" = "schedule" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| args+=(--refresh-all) | |
| fi | |
| java scripts/generate_readme.java generate README_SOURCE.md README.md .cache/github-stats.tsv "${args[@]}" --branch "$GITHUB_REF_NAME" | |
| - name: Commit README | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add README.md | |
| if git diff --staged --quiet; then | |
| echo "README is already current" | |
| else | |
| git commit -m "Update README with latest GitHub stats" | |
| git push | |
| fi |