try sharing whole environment #42
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 up environment | ||
run: | | ||
echo "R_LIBS_USER=$HOME/.local/share/R" >> $GITHUB_ENV | ||
echo "GITHUB_TOKEN=${{ secrets.AUTOMATISATION }}" >> $GITHUB_ENV | ||
echo "amiabot=${{ secrets.AMIABOT }}" >> $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 update | ||
sudo apt install -y libsodium-dev libcurl4-openssl-dev libgdal-dev libproj-dev libudunits2-dev libharfbuzz-dev libfribidi-dev | ||
- 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} | ||
- name: Save environment | ||
run: | | ||
mkdir -p $HOME/environment | ||
env > $HOME/environment/env_vars.txt | ||
dpkg -l > $HOME/environment/installed_packages.txt | ||
R -e "installed.packages()" > $HOME/environment/r_packages.txt | ||
- name: Upload environment | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: environment | ||
path: $HOME/environment | ||
build-queries: | ||
needs: setup-environment | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.AUTOMATISATION }} | ||
- name: Download environment | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: environment | ||
path: $HOME/environment | ||
- name: Restore environment | ||
run: | | ||
set -a | ||
source $HOME/environment/env_vars.txt | ||
set +a | ||
- 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: Download environment | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: environment | ||
path: $HOME/environment | ||
- name: Restore environment | ||
run: | | ||
set -a | ||
source $HOME/environment/env_vars.txt | ||
set +a | ||
- 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: Download environment | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: environment | ||
path: $HOME/environment | ||
- name: Restore environment | ||
run: | | ||
set -a | ||
source $HOME/environment/env_vars.txt | ||
set +a | ||
- 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: Download environment | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: environment | ||
path: $HOME/environment | ||
- name: Restore environment | ||
run: | | ||
set -a | ||
source $HOME/environment/env_vars.txt | ||
set +a | ||
- 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 |