Skip to content

Commit

Permalink
Merge pull request #302 from UTDNebula/270-bug-new-courses-missing-fr…
Browse files Browse the repository at this point in the history
…om-search-due-to-outdated-autocomplete-graph

Auto include new courses in autocomplete graph
  • Loading branch information
TyHil authored Feb 20, 2025
2 parents 8687579 + abc3623 commit 21b26ec
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 850,850 deletions.
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

0 comments on commit 21b26ec

Please sign in to comment.