44 schedule :
55 - cron : " 45 10 * * *"
66
7- env :
8- # GitHub username (owner of BOT_TOKEN, will be credited for updates)
9- BOT_USER : lc-bot
10- # Paths used to store cloned repositories
11- ACTION_REPO : thisrepo
12- DATA_REPO : thisrepo
13-
147defaults :
158 run :
169 shell : bash
2013 name : Run Data Update
2114 runs-on : ubuntu-latest
2215 env :
16+ REPO_DIR : main
2317 TIMESTAMP : X
2418 steps :
2519 - name : Store timestamp
@@ -28,32 +22,55 @@ jobs:
2822 - name : Checkout
2923 uses : actions/checkout@v4
3024 with :
31- path : ${{ env.ACTION_REPO }}
32- token : ${{ secrets.BOT_TOKEN }}
25+ path : ${{ env.REPO_DIR }}
26+ token : ${{ secrets.GITHUB_TOKEN }}
3327 - name : Setup python
3428 uses : actions/setup-python@v5
3529 with :
3630 python-version : " 3.11"
3731 cache : " pip"
38- cache-dependency-path : " ${{ env.DATA_REPO }}/_visualize/scripts/requirements.txt"
32+ cache-dependency-path : " ${{ env.REPO_DIR }}/_visualize/scripts/requirements.txt"
3933 - name : Install dependencies
40- run : pip install -r $DATA_REPO /_visualize/scripts/requirements.txt
34+ run : pip install -r $REPO_DIR /_visualize/scripts/requirements.txt
4135 - name : Run update script
42- run : ./$ACTION_REPO/.github/scripts/update.sh
36+ run : ./$REPO_DIR/.github/scripts/update.sh
37+ env :
38+ GITHUB_API_TOKEN : ${{ secrets.GITHUB_TOKEN }}
39+ - name : Create GitHub App Installation Token
40+ uses : actions/create-github-app-token@v2
41+ id : app-token
42+ with :
43+ app-id : ${{ vars.APP_ID }}
44+ private-key : ${{ secrets.PRIVATE_KEY }}
45+ - name : Get GitHub App User ID
46+ id : get-user-id
47+ run : echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
4348 env :
44- BOT_TOKEN : ${{ secrets.BOT_TOKEN }}
49+ GH_TOKEN : ${{ steps.app-token.outputs.token }}
50+ - name : Git config
51+ run : |
52+ git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
53+ git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
54+ - name : Commit updated data
55+ run : |
56+ git stash
57+ git pull --ff-only
58+ git stash pop
59+ git add -A .
60+ git commit -m "${{ env.TIMESTAMP }} Data Update by ${{ steps.app-token.outputs.app-slug }}"
61+ git push
4562 - name : Show health stats
4663 if : ${{ always() }}
4764 run : |
48- cat $DATA_REPO /_visualize/LAST_MASTER_UPDATE.txt || true
49- echo "Warning Count: $(grep -c 'Warning' $DATA_REPO /_visualize/LAST_MASTER_UPDATE.log)"
50- echo "From Timeouts: $(grep -c 'but failed' $DATA_REPO /_visualize/LAST_MASTER_UPDATE.log)"
51- echo "Limit Reached: $(grep -c 'rate limit exceeded' $DATA_REPO /_visualize/LAST_MASTER_UPDATE.log)"
65+ cat $REPO_DIR /_visualize/LAST_MASTER_UPDATE.txt || true
66+ echo "Warning Count: $(grep -c 'Warning' $REPO_DIR /_visualize/LAST_MASTER_UPDATE.log)"
67+ echo "From Timeouts: $(grep -c 'but failed' $REPO_DIR /_visualize/LAST_MASTER_UPDATE.log)"
68+ echo "Limit Reached: $(grep -c 'rate limit exceeded' $REPO_DIR /_visualize/LAST_MASTER_UPDATE.log)"
5269 - name : Save log files
5370 if : ${{ always() }}
5471 uses : actions/upload-artifact@v4
5572 with :
5673 name : logfiles_${{ env.TIMESTAMP }}_update
5774 path : |
58- ${{ env.DATA_REPO }}/_visualize/LAST_MASTER_UPDATE.txt
59- ${{ env.DATA_REPO }}/_visualize/LAST_MASTER_UPDATE.log
75+ ${{ env.REPO_DIR }}/_visualize/LAST_MASTER_UPDATE.txt
76+ ${{ env.REPO_DIR }}/_visualize/LAST_MASTER_UPDATE.log
0 commit comments