Scrape #172
This file contains hidden or 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: Scrape | |
| on: | |
| schedule: | |
| - cron: "0 12 * * 0" | |
| workflow_dispatch: | |
| jobs: | |
| scrape: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v2 | |
| - name: Set up R | |
| uses: r-lib/actions/setup-r@v2 | |
| with: | |
| r-version: '4.4.2' | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libcurl4-openssl-dev \ | |
| libssl-dev \ | |
| libxml2-dev \ | |
| libfontconfig1-dev \ | |
| libfreetype6-dev \ | |
| libpng-dev \ | |
| libtiff5-dev \ | |
| libjpeg-dev \ | |
| libharfbuzz-dev \ | |
| libfribidi-dev \ | |
| libgit2-dev \ | |
| libcairo2-dev \ | |
| libglpk-dev \ | |
| libudunits2-dev \ | |
| libmagick++-dev | |
| - name: Cache R packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/R/ | |
| key: ${{ runner.os }}-r-${{ hashFiles('Scraper.R') }} | |
| restore-keys: | | |
| ${{ runner.os }}-r- | |
| - name: Install R packages with pak | |
| run: | | |
| Rscript -e 'install.packages("pak", repos = "https://cloud.r-project.org")' | |
| Rscript -e 'pak::pkg_install(c("tidyverse", "rvest"))' | |
| - name: Run scraper script | |
| run: Rscript Scraper.R | |
| - name: Commit and push scraped data | |
| run: | | |
| git config --local user.name github-actions | |
| git config --local user.email "actions@github.com" | |
| if git status --porcelain | grep .; then | |
| git add Data/* | |
| git add logs.txt | |
| git commit -am "GH ACTION Autorun $(date)" | |
| git push origin main | |
| else | |
| echo "No changes to commit" | |
| fi | |
| env: | |
| REPO_KEY: ${{secrets.GITHUB_TOKEN}} | |
| username: github-actions |