Skip to content

Update GitHub API Cache #6

Update GitHub API Cache

Update GitHub API Cache #6

name: Update GitHub API Cache
on:
schedule:
- cron: '0 0 1 * *' # Runs at 00:00 on the 1st of every month
workflow_dispatch:
jobs:
update-cache:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Run api_process.py
run: python api_process.py
- name: Check for changes
id: git-check
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add js/cached-github-api-response.js
echo "changed=$(git diff --cached --quiet && echo 'false' || echo 'true')" >> $GITHUB_OUTPUT
- name: Commit and push if changed
if: steps.git-check.outputs.changed == 'true'
run: |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git commit -m "Regenerating cached GitHub API response - $(date +'%Y-%m-%d')" js/cached-github-api-response.js
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}