Generate courses #190
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: Generate courses | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 8 * * *' | |
concurrency: generate-courses | |
jobs: | |
run: | |
runs-on: ubuntu-latest | |
timeout-minutes: 45 | |
steps: | |
- name: Checkout main | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
path: main | |
- name: Checkout gh-pages | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
path: gh-pages | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests tqdm | |
- name: Generate courses | |
run: | | |
python -u ./main/courses_to_json.py last-2 \ | |
'./gh-pages/courses_{year}_{semester}.json' \ | |
--min-js-output-file='./gh-pages/courses_{year}_{semester}.min.js' \ | |
--last-semesters-output-file './gh-pages/last_semesters.json' \ | |
--run-postprocessing | |
- name: Deploy | |
run: | | |
cd gh-pages | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add . | |
git diff-index --quiet --cached HEAD || git commit -m "Update courses" | |
git push |