Auto Push Updated Score Info #5866
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |