Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto include new courses in autocomplete graph #302

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/update-autocomplete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Update course data from API

on: workflow_dispatch

jobs:
main:
name: Fetch and rebuild autocomplete graph and combos table
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Check out Git repository
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Create or reset the update branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout develop
git branch -D update-course-data || true # Delete branch if it exists locally
git checkout -b update-course-data

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install for ts-node
run: npm install

- name: Add API Key
run: echo "REACT_APP_NEBULA_API_KEY=${{ secrets.NEBULA_API_KEY }}" >> .env.local

- name: Fetch new data from api
run: npm run fetchdata

- name: Build autocomplete graph
run: npm run buildautocomplete

- name: Build combos table
run: npm run buildcombos

- name: Commit changes
run: |
git add .
git commit -m "Update course data from API"
git push -f origin update-course-data

- name: Create PR
uses: actions/github-script@v6
with:
script: |
const { repo, owner } = context.repo;
const pulls = await github.rest.pulls.list({
owner: owner,
repo: repo,
head: 'update-course-data',
base: 'develop',
state: 'open',
});

if (pulls.data.length < 1) {
await github.rest.pulls.create({
title: 'Update course data from API',
owner: owner,
repo: repo,
head: 'update-course-data',
base: 'develop',
body: [
'Fetch and rebuild autocomplete graph and combos table',
'',
'This PR is auto-generated by',
'[actions/github-script](https://github.com/actions/github-script)',
].join('\n'),
});
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"fetchdata": "ts-node -O \"{\\\"module\\\":\\\"commonjs\\\"}\" src/scripts/fetchAggregatedData.ts",
"buildautocomplete": "ts-node src/scripts/generateAutocompleteGraph.ts",
"buildcombos": "ts-node -O \"{\\\"module\\\":\\\"commonjs\\\"}\" src/scripts/generateCombosTable.ts",
"start": "next start",
Expand Down
1 change: 1 addition & 0 deletions src/data/aggregated_data.json

Large diffs are not rendered by default.

Loading
Loading