Update with Latest Data #422
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: Update with Latest Data | |
on: | |
push: | |
paths: | |
- DESCRIPTION | |
schedule: | |
- cron: '5 4 28-29 1-12 *' | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
env: | |
RSPM: https://packagemanager.rstudio.com/cran/__linux__/focal/latest | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: quarto-dev/quarto-actions/install-quarto@v1 | |
- run: | | |
quarto --version | |
- uses: r-lib/actions/setup-r@v2 | |
id: install-r | |
with: | |
r-version: 4.0.3 | |
- name: Query dependencies | |
run: | | |
install.packages('remotes') | |
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) | |
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") | |
shell: Rscript {0} | |
- name: Cache R packages | |
if: runner.os != 'Windows' | |
uses: actions/cache@v1 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} | |
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- | |
- name: Install system dependencies | |
if: runner.os == 'Linux' | |
env: | |
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc | |
GITHUB_PAT: ${{secrets.PAT}} | |
run: | | |
Rscript -e "remotes::install_github('r-hub/sysreqs', auth_toke = '${{secrets.GITHUB_TOKEN}}')" | |
Rscript -e "install.packages('stringi', type='source')" | |
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") | |
sudo -s eval "$sysreqs" | |
- name: Install dependencies | |
run: | | |
remotes::install_deps(dependencies = TRUE) | |
remotes::install_cran("rcmdcheck") | |
shell: Rscript {0} | |
- name: Session info | |
run: | | |
options(width = 100) | |
pkgs <- installed.packages()[, "Package"] | |
sessioninfo::session_info(pkgs, include_base = TRUE) | |
shell: Rscript {0} | |
- name: Run script | |
env: | |
ACCESS_SECRET: ${{ secrets.ACCESS_SECRET }} | |
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
CONSUMER_KEY: ${{ secrets.CONSUMER_KEY }} | |
CONSUMER_SECRET: ${{ secrets.CONSUMER_SECRET }} | |
run: |- | |
Rscript -e "source('scrape.R')" | |
- name: Aggregate results | |
run: |- | |
Rscript -e "source('aggregate.R')" | |
- name: Commit results | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "Michael DeWitt" | |
git add . | |
git commit -m "Update the latest data" -a || echo "No changes to commit" | |
git push https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git HEAD:${{ github.ref }} || echo "No changes to commit" | |
- id: release | |
run: | | |
patch_version=${{ github.event.inputs.patch_version }} | |
[ ! -z $patch_version ] && patch_version="."$patch_version | |
# if so, append to usual montly number | |
current_tag="$(date '+%Y.%m.%d')${patch_version}" | |
daily_release="v${current_tag}" | |
git tag -f $daily_release | |
git push | |
git push -f --tags | |
- name: Check Output Parameters | |
run: | | |
echo "Got tag name ${{ steps.release.outputs.tag_name }}" | |
echo "Got release version ${{ steps.release.outputs.version }}" |