ABS_labour_force_report #33
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: ABS_labour_force_report | |
on: | |
# Workflow scheduled to run at 00:00 UTC on the 1st of every month. | |
schedule: | |
- cron: "0 0 1 * *" | |
# Workflow can also be run manually from the Actions tab | |
workflow_dispatch: | |
# Constructs a job to load the runner, set up the R environment, run scripts and git commit | |
jobs: | |
run_report: | |
runs-on: ubuntu-latest | |
# Retrieves secrets from GitHub and set renv root path | |
env: | |
apikey: ${{ secrets.APIKEY }} | |
apisecretkey: ${{ secrets.APISECRETKEY }} | |
access_token: ${{ secrets.ACCESS_TOKEN }} | |
access_token_secret: ${{ secrets.ACCESS_TOKEN_SECRET }} | |
RENV_PATHS_ROOT: ~/.local/share/renv | |
steps: | |
# Checks out your repository under $GITHUB_WORKSPACE so your job can access it | |
- uses: actions/checkout@v2 | |
# Sets up pandoc which is required for knitting HTML reports | |
- uses: r-lib/actions/setup-pandoc@v2 | |
with: | |
pandoc-version: '2.17.1' | |
# Set up R environment 4.1.2 | |
- name: Setup R version 4.1.2 | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: '4.1.2' | |
# Set up R packages cache for workflow reruns | |
- name: Cache R packages | |
uses: actions/cache@v1 | |
with: | |
path: ${{ env.RENV_PATHS_ROOT }} | |
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }} | |
restore-keys: |- | |
${{ runner.os }}-renv- | |
# Install cURL to transfer data to virtual environment | |
- run: sudo apt-get install -y --no-install-recommends libcurl4-openssl-dev | |
# Install renv and project specific R packages | |
- name: Restore R packages | |
shell: Rscript {0} | |
run: | | |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv") | |
renv::restore() | |
# Executes R scripts | |
- name: Extract data from ABS labour force data API | |
run: Rscript code/01_extract_data.R | |
- name: Clean raw labour force data | |
run: Rscript code/02_clean_data.R | |
- name: Render labour force reports | |
run: Rscript code/03_automate_reports.R | |
# Commits newly rendered reports into the repository | |
- name: Commit new data and reports | |
run: | | |
git config --local user.email "erikaduan@github.com" | |
git config --local user.name "Erika Duan" | |
git commit -am ":package: refresh and produce new report version" | |
git push |