Skip to content

Data

Data #356

Workflow file for this run

name: Data
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
permissions:
contents: write
pull-requests: write
jobs:
generate-data:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: main
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 22
cache: npm
- name: Create branch
run: |
git checkout -b generate-data
git reset --hard origin/main
- name: Update courseData.json
run: node scripts/generateCourseData.mjs 10000 > static/courseData.json
- name: Update static/_catalogs
run: |
set -e
node scripts/generateCatalogsRaw.mjs
node scripts/generateCatalogsStatic.mjs
- name: Check if data has changed
run: |
if git diff --quiet static/courseData.json && git diff --quiet static/_catalogs; then
echo "No changes to static/_catalogs or static/courseData.json, stopping the workflow."
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
fi
- name: Push changes to new branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add static/courseData.json
git add static/_catalogs
git commit -m "[Automated] Update data"
git push --force origin generate-data
- name: Create Pull Request
env:
GH_TOKEN: ${{ github.token }}
run: |
DATE=$(date +'%d-%m-%Y')
gh pr create --base main --head generate-data \
--title "[Automated] Update course data $DATE" \
--body "This automated PR updates the \`static/courseData.json\` file."