-
Notifications
You must be signed in to change notification settings - Fork 58
134 lines (116 loc) · 4.1 KB
/
update.yml
File metadata and controls
134 lines (116 loc) · 4.1 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Routine Data Update
on:
workflow_dispatch:
schedule:
- cron: '45 9 * * *'
concurrency:
group: data-updates
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
runDataUpdate:
if: github.ref == 'refs/heads/main'
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 $REPO_DIR/_visualize/scripts/requirements.txt
- name: Create GitHub App Installation Token1
uses: actions/create-github-app-token@v3
id: app-token1
with:
app-id: ${{ vars.CLIENT_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- name: Run data collection script with App Installation Token
run: |
set -eu
cd $REPO_DIR/_visualize/scripts
./UPDATE.sh $TAG
env:
GITHUB_API_TOKEN: ${{ steps.app-token1.outputs.token }}
TAG: MEMBERS
- name: Validate members data updates
run: ./$REPO_DIR/.github/scripts/validate.sh
env:
TAG: MEMBERS
- name: Run data collection script with Action Token
run: |
set -eu
cd $REPO_DIR/_visualize/scripts
./UPDATE.sh $TAG
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: CORE
- name: Validate core data updates
run: ./$REPO_DIR/.github/scripts/validate.sh
env:
TAG: CORE
- name: Create GitHub App Installation Token
uses: actions/create-github-app-token@v3
id: app-token
with:
app-id: ${{ vars.CLIENT_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: |
set -eu
cd $REPO_DIR
git stash
git pull --ff-only
git stash pop
git add -A .
git commit -m "$TIMESTAMP Data Update by ${{ steps.app-token.outputs.app-slug }}"
git push
- name: Show health stats
if: ${{ always() }}
run: |
for TAG in MEMBERS CORE; do
cat $REPO_DIR/_visualize/LAST_${TAG}_UPDATE.txt || true
echo "Warning Count: $(grep -c 'Warning' $REPO_DIR/_visualize/LAST_${TAG}_UPDATE.log)"
echo "From Timeouts: $(grep -c 'but failed' $REPO_DIR/_visualize/LAST_${TAG}_UPDATE.log)"
echo "Limit Reached: $(grep -c 'rate limit exceeded' $REPO_DIR/_visualize/LAST_${TAG}_UPDATE.log)"
done
- name: Save log files
if: ${{ always() }}
uses: actions/upload-artifact@v6
with:
name: logfiles_${{ env.TIMESTAMP }}_update
path: |
${{ env.REPO_DIR }}/_visualize/LAST_MEMBERS_UPDATE.txt
${{ env.REPO_DIR }}/_visualize/LAST_MEMBERS_UPDATE.log
${{ env.REPO_DIR }}/_visualize/LAST_CORE_UPDATE.txt
${{ env.REPO_DIR }}/_visualize/LAST_CORE_UPDATE.log