Update Organization Stats #116
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 Organization Stats | |
| # ⚠️ REQUIRED: Organization Settings → Actions → General → Workflow permissions | |
| # must be set to "Read and write permissions" for this workflow to push commits. | |
| on: | |
| # Twice daily: 06:00 UTC and 18:00 UTC | |
| schedule: | |
| - cron: "0 6 * * *" | |
| - cron: "0 18 * * *" | |
| # Manual trigger | |
| workflow_dispatch: | |
| # Also run on push to master (to verify script changes only — won't push) | |
| push: | |
| branches: [master] | |
| paths: | |
| - "scripts/update_stats.py" | |
| - ".github/workflows/update-stats.yml" | |
| jobs: | |
| update-stats: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: master | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| persist-credentials: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Run stats update | |
| id: stats | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: python3 scripts/update_stats.py | |
| - name: Commit and push if changed | |
| if: steps.stats.outputs.changed == 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add profile/README.md | |
| git diff --cached --quiet && echo "No diff to commit" && exit 0 | |
| git commit -m "chore(stats): auto-update organization statistics [skip ci]" | |
| git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/EUR-UN/.github.git" | |
| git push origin master |