download occurrence cube #41
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: download occurrence cube | |
on: | |
workflow_dispatch: # Manual | |
push: | |
branches: # Changes to GRIIS Checklist | |
- "uat" | |
paths: | |
- "data/output/UAT_processing/data_input_checklist_indicators.tsv" | |
schedule: | |
- cron: '0 0 1 1-12 *' # 1st of the month 00:00 between january & december | |
env: | |
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true | |
GITHUB_TOKEN: ${{ secrets.AUTOMATISATION }} | |
amiabot: ${{ secrets.AMIABOT }} | |
jobs: | |
setup-environment: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.AUTOMATISATION }} | |
- name: Set R library path | |
run: echo "R_LIBS_USER=$HOME/.local/share/R" >> $GITHUB_ENV | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: 'release' | |
- name: Setup pandoc | |
uses: r-lib/actions/setup-pandoc@v2 | |
- name: Install linux libraries | |
run: | | |
sudo apt install libsodium-dev libcurl4-openssl-dev libgdal-dev libproj-dev libudunits2-dev libharfbuzz-dev libfribidi-dev | |
- name: Cache R packages | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-r-${{ hashFiles('**/install_packages_cube*.R') }} | |
restore-keys: | | |
${{ runner.os }}-r- | |
- name: Install R packages | |
run: | | |
source("src/get_cubes/install_packages_cube_base.R") | |
source("src/get_cubes/install_packages_cube_extra.R") | |
shell: Rscript {0} | |
build-queries: | |
needs: setup-environment | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.AUTOMATISATION }} | |
- name: Set R library path | |
run: echo "R_LIBS_USER=$HOME/.local/share/R" >> $GITHUB_ENV | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: 'release' | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-r-${{ hashFiles('**/install_packages_cube*.R') }} | |
- name: create queries | |
run: source("src/get_cubes/run_build_queries.R") | |
shell: Rscript {0} | |
- name: upload queries | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./data/interim/cube_queries/* | |
download-cubes: | |
needs: build-queries | |
runs-on: ubuntu-latest | |
env: | |
gbif_user: ${{ secrets.GBIF_USER }} | |
email: ${{ secrets.GBIF_EMAIL }} | |
gbif_pwd: ${{ secrets.GBIF_PWD }} | |
strategy: | |
matrix: | |
param_value: ["FAMILY", "GENUS", "SPECIES", "SUBSPECIES_FORM_VARIETY", "CLASS"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.AUTOMATISATION }} | |
- name: Set R library path | |
run: echo "R_LIBS_USER=$HOME/.local/share/R" >> $GITHUB_ENV | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: 'release' | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-r-${{ hashFiles('**/install_packages_cube*.R') }} | |
- name: download queries | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./data/interim/cube_queries/* | |
- name: download cubes | |
run: | | |
Rscript -e "rmarkdown::render('src/get_cubes/download_cubes.Rmd', params = list(rank = '${{ matrix.param_value }}'), knit_root_dir = '../../')" | |
- name: Upload cube artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.param_value == 'CLASS' && 'be_classes_cube_raw' || format('be_alientaxa_cube_{0}', matrix.param_value) }}.csv | |
path: ./cube_data/ | |
compile-cubes: | |
needs: download-cubes | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.AUTOMATISATION }} | |
- name: Set R library path | |
run: echo "R_LIBS_USER=$HOME/.local/share/R" >> $GITHUB_ENV | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: 'release' | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-r-${{ hashFiles('**/install_packages_cube*.R') }} | |
- name: download rank cubes artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: be_alientaxa_cube_* | |
merge-multiple: true | |
path: ./cube_data/ | |
- name: compile cubes | |
run: source("src/get_cubes/run_compile_cubes.R") | |
shell: Rscript {0} | |
- name: upload occ cube | |
uses: actions/upload-artifact@v4 | |
with: | |
name: be_alientaxa_cube.csv | |
path: ./cube_data/be_alientaxa_cube.csv | |
compile-class-cube: | |
needs: download-cubes | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.AUTOMATISATION }} | |
- name: Set R library path | |
run: echo "R_LIBS_USER=$HOME/.local/share/R" >> $GITHUB_ENV | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: 'release' | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-r-${{ hashFiles('**/install_packages_cube*.R') }} | |
- name: download class cube artifact | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: be_classes_cube_raw | |
merge-multiple: true | |
path: ./cube_data/ | |
- name: compile class cube | |
run: source("src/get_cubes/run_compile_class_cube.R") | |
shell: Rscript {0} | |
- name: upload class cube | |
uses: actions/upload-artifact@v4 | |
with: | |
name: be_classes_cube.csv | |
path: ./cube_data/be_classes_cube.csv |