generated from PeiPei233/zju-score-push-template
-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (43 loc) · 1.47 KB
/
update_push.yaml
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
name: Auto Push Updated Score Info
on:
schedule:
- cron: '*/40 * * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Setup Python Environment
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Get Score Assistant Repo
run: git clone https://github.com/PeiPei233/ZJUScoreAssistant.git
- name: Install Python Dependencies
run: pip install -r ZJUScoreAssistant/requirements.txt
- name: Run Python Script
run: |
echo '${{ vars.dingscore1 }}' > dingscore.json
echo "{\"username\": \"$USERNAME\", \"password\": \"$PASSWORD\", \"url\": \"$WEBHOOK\"}" > database.json
timeout 30s python ZJUScoreAssistant/zjuscore.py -dn || true
env:
USERNAME: ${{ secrets.USERNAME }}
PASSWORD: ${{ secrets.PASSWORD }}
WEBHOOK: ${{ secrets.WEBHOOK }}
- name: Install jq
run: sudo apt-get install jq
- name: Compare and update dingscore1
run: |
current_dingscore1='${{ vars.dingscore1 }}'
new_dingscore=$(jq -c . < dingscore.json)
if [ "$new_dingscore" != "$current_dingscore1" ]; then
echo "dingscore1 is different. Updating..."
gh variable set dingscore1 --body "$new_dingscore"
else
echo "dingscore1 is the same. No update needed."
fi
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}