-
Notifications
You must be signed in to change notification settings - Fork 3
51 lines (46 loc) · 1.49 KB
/
scraper.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
name: Scraper
on:
schedule:
- cron: '0 5 * * MON'
workflow_dispatch:
jobs:
scrape:
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.SCRAPER_APP_ID }}
private-key: ${{ secrets.SCRAPER_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Run scraper
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
bundle exec rake scraper
sed -i -e 's/ $//' db/data/*.yml
git add db/data
if ! git diff --cached --quiet;
then
git config --global user.email "[email protected]"
git config --global user.name "MiCarrera"
git commit -m 'chore: update scraped subjects data'
git push -f origin HEAD:scraper
if [ $(gh pr list --head scraper --json title --jq 'length') == '0' ];
then
gh pr create \
--title "Update scraped subjects data" \
--body "This PR runs `rails scraper` to update scraped subjects' data" \
--head scraper
else
echo "A PR already exists and was correctly updated."
fi
else
echo "There were no changes. Nothing to do."
fi