-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (74 loc) · 2 KB
/
scrape.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Auto-format code with Prettier
on:
workflow_dispatch:
inputs:
year:
description: Last two digits of the year
required: true
type: string
quarter:
description: Quarter
required: true
type: choice
options:
- FA
- WI
- SP
- SU
- S1
- S2
- S3
- Summer
concurrency:
group: ${{ github.workflow }}
permissions:
contents: write
jobs:
scrape:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Scrape UCSD schedules (non-summer)
if: ${{ inputs.quarter != 'Summer' }}
env:
TERM: ${{ inputs.quarter }}${{ inputs.year }}
run: |
echo "Scraping $TERM"
deno task classrooms:scrape-to-file
- name: Scrape UCSD schedules (summer)
if: ${{ inputs.quarter == 'Summer' }}
env:
YEAR: ${{ inputs.year }}
run: |
echo "Scraping $YEAR summer"
for quarter in SU S1 S2 S3
do
export TERM="$quarter$YEAR"
echo "Scraping $TERM"
deno task classrooms:scrape-to-file
done
- name: Upload scraped data
uses: actions/upload-artifact@v4
with:
name: data
path: ./classrooms/data/
upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages
- uses: actions/download-artifact@v4
with:
name: data
path: ~/data/
- name: Push scraped data to gh-pages
env:
TERM: ${{ inputs.quarter == 'Summer' && format('Summer {0}', inputs.year) || format('{0}{1}', inputs.quarter, inputs.year) }}
run: |
cp -v ~/data/* ./data/
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add ./data/
git commit -m "Scrape $TERM"
git push