Skip to content

Manually update workflows to dockerised versions #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
246 changes: 180 additions & 66 deletions .github/workflows/README.md

Large diffs are not rendered by default.

132 changes: 132 additions & 0 deletions .github/workflows/docker_apply_cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
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: Cache renv Directory
uses: actions/cache@v4
with:
path: /home/rstudio/lesson/renv
key: ${{ runner.os }}-${{ inputs.cache-version }}-renv-${{ needs.prepare.outputs.renv-cache-hashsum }}
restore-keys:
${{ runner.os }}-${{ inputs.cache-version }}-renv-
Loading