Fetch GitHub API Meta #2577
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: Fetch GitHub API Meta | |
| on: | |
| schedule: | |
| - cron: '0 * * * *' # Every hour | |
| workflow_dispatch: # Allow manual triggers | |
| permissions: | |
| contents: write | |
| jobs: | |
| fetch-and-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Fetch GitHub API /meta | |
| run: | | |
| HTTP_STATUS=$(curl -sSL -o /tmp/meta.json -w "%{http_code}" https://api.github.com/meta) | |
| if [ "$HTTP_STATUS" -ne 200 ]; then | |
| echo "Unexpected HTTP status: $HTTP_STATUS. Skipping meta.json update and commit." | |
| exit 0 | |
| fi | |
| jq . /tmp/meta.json > meta.json | |
| - name: Commit changes if any | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add meta.json | |
| if git diff --cached --quiet; then | |
| echo "No changes detected." | |
| else | |
| git commit -m "Update meta.json — $(date -u +'%Y-%m-%dT%H:%M:%SZ')" | |
| git push | |
| fi |