Skip to content

Use cache to store leaderboard data across streams #5

Use cache to store leaderboard data across streams

Use cache to store leaderboard data across streams #5

Workflow file for this run

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: Save leaderboards to cache
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