Scraper #65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Scraper | |
on: | |
schedule: | |
- cron: '0 5 * * MON' | |
workflow_dispatch: | |
jobs: | |
scrape: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Run scraper | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_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 |