Update 3 packages #26
Workflow file for this run
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: "03 Maintain: Apply Package Cache" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| name: | |
| description: 'Who triggered this build?' | |
| required: true | |
| default: 'Maintainer (via GitHub)' | |
| pull_request: | |
| types: | |
| - closed | |
| jobs: | |
| preflight: | |
| name: "Preflight: PR or Manual Trigger?" | |
| runs-on: ubuntu-latest | |
| outputs: | |
| do-apply: ${{ steps.check.outputs.merged_or_manual }} | |
| steps: | |
| - name: "Should we run cache application?" | |
| id: check | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" || | |
| ("${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged }}" == "true") ]]; then | |
| echo "merged_or_manual=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "This was not a manual trigger and no PR was merged. No action taken." | |
| echo "merged_or_manual=false" >> $GITHUB_OUTPUT | |
| fi | |
| check-renv: | |
| name: "Check If We Need {renv}" | |
| runs-on: ubuntu-latest | |
| needs: preflight | |
| if: ${{ needs.preflight.outputs.do-apply == 'true' }} | |
| outputs: | |
| renv-needed: ${{ steps.check-for-renv.outputs.exists }} | |
| steps: | |
| - name: "Checkout Lesson" | |
| uses: actions/checkout@v4 | |
| - name: "Check for renv" | |
| id: check-for-renv | |
| run: | | |
| if [[ -d renv ]]; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| fi | |
| prepare: | |
| name: "Grab renv.lock hash" | |
| runs-on: ubuntu-latest | |
| needs: check-renv | |
| if: ${{ needs.check-renv.outputs.renv-needed == 'true' }} | |
| outputs: | |
| renv-cache-hashsum: ${{ steps.set-hash.outputs.renv-cache-hashsum }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Calculate renv hash | |
| id: set-hash | |
| run: | | |
| echo "renv-cache-hashsum=${{ hashFiles('renv/profiles/lesson-requirements/renv.lock') }}" >> $GITHUB_OUTPUT | |
| update-renv-cache: | |
| name: "Update renv Cache" | |
| if: | | |
| github.event_name == 'workflow_dispatch' || | |
| ( | |
| github.event.pull_request.merged == true && | |
| contains( | |
| join(github.event.pull_request.labels.*.name, ','), | |
| 'type: package cache' | |
| ) | |
| ) | |
| runs-on: ubuntu-latest | |
| needs: prepare | |
| permissions: | |
| checks: write | |
| contents: write | |
| pages: write | |
| container: | |
| image: carpentries/workbench-docker:${{ vars.WORKBENCH_TAG || 'latest' }} | |
| env: | |
| WORKBENCH_PROFILE: "ci" | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| RENV_PATHS_ROOT: /home/rstudio/lesson/renv | |
| RENV_PROFILE: "lesson-requirements" | |
| RENV_VERSION: ${{ needs.prepare.outputs.renv-cache-hashsum }} | |
| RENV_CONFIG_EXTERNAL_LIBRARIES: "/usr/local/lib/R/site-library" | |
| volumes: | |
| - ${{ github.workspace }}:/home/rstudio/lesson | |
| options: --cpus 2 | |
| steps: | |
| - name: "Checkout Lesson" | |
| uses: actions/checkout@v4 | |
| - name: Current env | |
| run: env | sort | |
| - name: Debugging Info | |
| run: | | |
| echo "Current Directory: $(pwd)" | |
| ls -lah /home/rstudio/.workbench | |
| ls -lah $(pwd) | |
| Rscript -e 'sessionInfo()' | |
| - name: Mark Repository as Safe | |
| run: | | |
| git config --global --add safe.directory $(pwd) | |
| - name: "Ensure sandpaper is loadable" | |
| run: | | |
| .libPaths() | |
| library(sandpaper) | |
| shell: Rscript {0} | |
| - name: Setup Lesson Dependencies | |
| run: | | |
| Rscript /home/rstudio/.workbench/setup_lesson_deps.R | |
| - name: Fortify renv Cache | |
| run: | | |
| Rscript /home/rstudio/.workbench/fortify_renv_cache.R | |
| - name: Get Container Version Used | |
| run: | | |
| tag=${{ vars.WORKBENCH_TAG || 'latest' }} | |
| digest=$(curl -s "https://hub.docker.com/v2/repositories/carpentries/workbench-docker/tags?name=$tag" | jq -r '.results[] | select(.name == "'$tag'") | .digest') | |
| if [[ "$tag" == "latest" ]]; then | |
| vers=$(curl -s "https://hub.docker.com/v2/repositories/carpentries/workbench-docker/tags" | jq -r '.results[] | select(.digest == "'$digest'") | .name') | |
| ver=$(echo "$vers" | grep -Po "^v.*") | |
| else | |
| ver="$tag" | |
| fi | |
| echo "CONTAINER_VER=$ver" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Cache renv Directory | |
| uses: actions/cache@v4 | |
| with: | |
| path: /home/rstudio/lesson/renv | |
| key: ${{ env.CONTAINER_VER }}-${{ inputs.cache-version }}-renv-${{ needs.prepare.outputs.renv-cache-hashsum }} | |
| restore-keys: | |
| ${{ env.CONTAINER_VER }}-${{ inputs.cache-version }}-renv- |