-
Notifications
You must be signed in to change notification settings - Fork 46
46 lines (38 loc) · 1.49 KB
/
update-github-cache.yml
File metadata and controls
46 lines (38 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.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 }}