Repository navigation
Refresh README statistics #27
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: Refresh README statistics | |
| on: | |
| schedule: | |
| - cron: '23 * * * *' | |
| workflow_dispatch: | |
| pull_request: | |
| paths: | |
| - .github/scripts/readme-stats.py | |
| - .github/workflows/readme-stats.yml | |
| - tests/test_readme_stats.py | |
| concurrency: | |
| group: readme-stats-${{ github.event_name == 'pull_request' && github.head_ref || 'master' }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - run: python3 -m unittest discover -s tests -p 'test_readme_stats.py' -v | |
| - name: Check live metric sources | |
| if: github.event_name == 'pull_request' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| DOCKERHUB_IMAGE: ${{ vars.DOCKERHUB_IMAGE }} | |
| run: python3 .github/scripts/readme-stats.py | |
| refresh: | |
| needs: validate | |
| if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| commit: ${{ steps.commit.outputs.sha }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: master | |
| fetch-depth: 0 | |
| - name: Collect and render current metrics | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| DOCKERHUB_IMAGE: ${{ vars.DOCKERHUB_IMAGE }} | |
| run: python3 .github/scripts/readme-stats.py | |
| - name: Commit statistics only | |
| id: commit | |
| run: | | |
| git config user.name 'github-actions[bot]' | |
| git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
| git add README.md docs/stats | |
| if ! git diff --cached --quiet; then | |
| git commit -m 'Refresh repository statistics [skip ci]' | |
| git pull --rebase origin master | |
| git push origin HEAD:master | |
| fi | |
| echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
| overview: | |
| needs: refresh | |
| permissions: | |
| contents: read | |
| uses: ./.github/workflows/dockerhub-overview.yml | |
| with: | |
| ref: ${{ needs.refresh.outputs.commit }} | |
| secrets: | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} |