-
Notifications
You must be signed in to change notification settings - Fork 1
124 lines (104 loc) · 3.04 KB
/
trigger.yml
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
name: Trigger
on:
- workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Restore leaderboards
uses: actions/cache/restore@v3
id: restore-leaderboards
with:
path: |
chatdownloader/*.json
key: ${{ hashFiles('season.txt') }}
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'poetry'
- name: Install pip Dependencies
working-directory: chatdownloader/
run: |
python -m pip install --upgrade pip
pip install .
- name: Run score calculation
env:
ACT: ${{ vars.ACT }}
TWITCH_APPID: ${{ secrets.TWITCH_APPID }}
TWITCH_APPSECRET: ${{ secrets.TWITCH_APPSECRET }}
working-directory: chatdownloader/
run: |
if [ "${ACT}" == "1" ]; then
echo "On Act, backfilling instead."
python src/backfill.py
else
echo "On actual pipeline, running main"
python src/main.py
fi
- name: Stage files
run: |
./stage.sh
- name: Delete old cache
env:
CACHE_NAME: ${{ steps.restore-leaderboards.outputs.cache-primary-key }}
REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${ACT}" == "1" ]; then
echo "On Act, skipping."
exit 0
fi
echo "Deleting old cache"
gh extension install actions/gh-actions-cache
gh actions-cache delete ${CACHE_NAME} -R $REPO --confirm || exit 0
- name: Save leaderboards to cache
uses: actions/cache/save@v3
with:
path: |
chatdownloader/*.json
key: ${{ steps.restore-leaderboards.outputs.cache-primary-key }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache-dependency-path: 'web/package-lock.json'
cache: 'npm'
- name: Install npm dependencies
working-directory: web/
run: npm install
- name: Build website
working-directory: web/
run: npm run build
- name: Upload build Files
uses: actions/upload-artifact@v3 # NOTE: v3 to support act
with:
name: build
path: ./web/build
- name: Clean Directory and Checkout to Another Branch
run: |
git reset --hard
git clean -fd
- name: Checkout to publish branch
uses: actions/checkout@v4
with:
ref: 'publish'
- name: Clean directory again
run: |
git reset --hard
git clean -fd
- name: Download Build Files
uses: actions/download-artifact@v3
with:
name: build
path: .
- name: Commit and Push Changes
run: |
git config --global user.name 'Bot'
git config --global user.email 'bot@github.com'
git add . || exit 0
git commit -m "Update leaderboards" || exit 0
git push origin publish || exit 0