-
Notifications
You must be signed in to change notification settings - Fork 58
85 lines (82 loc) · 3.04 KB
/
update.yml
File metadata and controls
85 lines (82 loc) · 3.04 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Routine Data Update
on:
workflow_dispatch:
schedule:
- cron: "45 10 * * *"
defaults:
run:
shell: bash
jobs:
runDataUpdate:
name: Run Data Update
runs-on: ubuntu-latest
env:
REPO_DIR: main
TIMESTAMP: X
steps:
- name: Store timestamp
run: |
echo "TIMESTAMP=$(date -u +"%F-%H")" >> "$GITHUB_ENV"
- name: Checkout
uses: actions/checkout@v6
with:
path: ${{ env.REPO_DIR }}
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Setup python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: "${{ env.REPO_DIR }}/_visualize/scripts/requirements.txt"
- name: Install dependencies
run: pip install -r ${{ env.REPO_DIR }}/_visualize/scripts/requirements.txt
- name: Run update script
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./${{ env.REPO_DIR }}/.github/scripts/update.sh
- name: Create GitHub App Installation Token
uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- name: Get GitHub App User ID
id: get-user-id
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
- name: Configure git
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh auth setup-git
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
- name: Commit updated data
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
pushd ${{ env.REPO_DIR }}
git stash
git pull --ff-only
git stash pop
git add -A .
git commit -m "${{ env.TIMESTAMP }} Data Update by ${{ steps.app-token.outputs.app-slug }}"
git push
popd
- name: Show health stats
if: ${{ always() }}
run: |
cat ${{ env.REPO_DIR }}/_visualize/LAST_MASTER_UPDATE.txt || true
echo "Warning Count: $(grep -c 'Warning' ${{ env.REPO_DIR }}/_visualize/LAST_MASTER_UPDATE.log)"
echo "From Timeouts: $(grep -c 'but failed' ${{ env.REPO_DIR }}/_visualize/LAST_MASTER_UPDATE.log)"
echo "Limit Reached: $(grep -c 'rate limit exceeded' ${{ env.REPO_DIR }}/_visualize/LAST_MASTER_UPDATE.log)"
- name: Save log files
if: ${{ always() }}
uses: actions/upload-artifact@v6
with:
name: logfiles_${{ env.TIMESTAMP }}_update
path: |
${{ env.REPO_DIR }}/_visualize/LAST_MASTER_UPDATE.txt
${{ env.REPO_DIR }}/_visualize/LAST_MASTER_UPDATE.log