Skip to content

Commit f02a8a7

Browse files
tobyhodgesgithub-actions[bot]
authored andcommitted
[actions] update sandpaper workflow to version 0.18.5
1 parent 96ad2a9 commit f02a8a7

File tree

9 files changed

+1096
-165
lines changed

9 files changed

+1096
-165
lines changed

.github/workflows/README.md

Lines changed: 180 additions & 66 deletions
Large diffs are not rendered by default.
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
name: "03 Maintain: Apply Package Cache"
2+
description: "Generate the package cache for the lesson after a pull request has been merged or via manual trigger, and cache in S3 or GitHub"
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
name:
7+
description: 'Who triggered this build?'
8+
required: true
9+
default: 'Maintainer (via GitHub)'
10+
pull_request:
11+
types:
12+
- closed
13+
branches:
14+
- main
15+
16+
# queue cache runs
17+
concurrency:
18+
group: docker-apply-cache
19+
cancel-in-progress: false
20+
21+
jobs:
22+
preflight:
23+
name: "Preflight: PR or Manual Trigger?"
24+
runs-on: ubuntu-latest
25+
outputs:
26+
do-apply: ${{ steps.check.outputs.merged_or_manual }}
27+
steps:
28+
- name: "Should we run cache application?"
29+
id: check
30+
run: |
31+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ||
32+
("${{ github.ref }}" == "refs/heads/main" && "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged }}" == "true") ]]; then
33+
echo "merged_or_manual=true" >> $GITHUB_OUTPUT
34+
else
35+
echo "This was not a manual trigger and no PR was merged. No action taken."
36+
echo "merged_or_manual=false" >> $GITHUB_OUTPUT
37+
fi
38+
shell: bash
39+
40+
check-renv:
41+
name: "Check If We Need {renv}"
42+
runs-on: ubuntu-latest
43+
needs: preflight
44+
if: needs.preflight.outputs.do-apply == 'true'
45+
permissions:
46+
id-token: write
47+
outputs:
48+
renv-needed: ${{ steps.check-for-renv.outputs.renv-needed }}
49+
renv-cache-hashsum: ${{ steps.check-for-renv.outputs.renv-cache-hashsum }}
50+
renv-cache-available: ${{ steps.check-for-renv.outputs.renv-cache-available }}
51+
steps:
52+
- name: "Check for renv"
53+
id: check-for-renv
54+
uses: carpentries/actions/renv-checks@main
55+
with:
56+
role-to-assume: ${{ secrets.AWS_GH_OIDC_ARN }}
57+
aws-region: ${{ secrets.AWS_GH_OIDC_REGION }}
58+
WORKBENCH_TAG: ${{ vars.WORKBENCH_TAG || 'latest' }}
59+
token: ${{ secrets.GITHUB_TOKEN }}
60+
61+
no-renv-cache-used:
62+
name: "No renv cache used"
63+
runs-on: ubuntu-latest
64+
needs: check-renv
65+
if: needs.check-renv.outputs.renv-needed != 'true'
66+
steps:
67+
- name: "No renv cache needed"
68+
run: echo "No renv cache needed for this lesson"
69+
70+
renv-cache-available:
71+
name: "renv cache available"
72+
runs-on: ubuntu-latest
73+
needs: check-renv
74+
if: needs.check-renv.outputs.renv-cache-available == 'true'
75+
steps:
76+
- name: "renv cache available"
77+
run: echo "renv cache available for this lesson"
78+
79+
update-renv-cache:
80+
name: "Update renv Cache"
81+
runs-on: ubuntu-latest
82+
needs: check-renv
83+
if: |
84+
needs.check-renv.outputs.renv-needed == 'true' &&
85+
needs.check-renv.outputs.renv-cache-available != 'true' &&
86+
(
87+
github.event_name == 'workflow_dispatch' ||
88+
(
89+
github.event.pull_request.merged == true &&
90+
(
91+
(
92+
contains(
93+
join(github.event.pull_request.labels.*.name, ','),
94+
'type: package cache'
95+
) &&
96+
github.event.pull_request.head.ref == 'update/packages'
97+
)
98+
||
99+
(
100+
contains(
101+
join(github.event.pull_request.labels.*.name, ','),
102+
'type: workflows'
103+
) &&
104+
github.event.pull_request.head.ref == 'update/workflows'
105+
)
106+
||
107+
(
108+
contains(
109+
join(github.event.pull_request.labels.*.name, ','),
110+
'type: docker version'
111+
) &&
112+
github.event.pull_request.head.ref == 'update/workbench-docker-version'
113+
)
114+
)
115+
)
116+
)
117+
permissions:
118+
checks: write
119+
contents: write
120+
pages: write
121+
id-token: write
122+
container:
123+
image: ghcr.io/carpentries/workbench-docker:${{ vars.WORKBENCH_TAG || 'latest' }}
124+
env:
125+
WORKBENCH_PROFILE: "ci"
126+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
127+
RENV_PATHS_ROOT: /home/rstudio/lesson/renv
128+
RENV_PROFILE: "lesson-requirements"
129+
RENV_VERSION: ${{ needs.check-renv.outputs.renv-cache-hashsum }}
130+
RENV_CONFIG_EXTERNAL_LIBRARIES: "/usr/local/lib/R/site-library"
131+
volumes:
132+
- ${{ github.workspace }}:/home/rstudio/lesson
133+
options: --cpus 2
134+
steps:
135+
- uses: actions/checkout@v4
136+
137+
- name: "Debugging Info"
138+
run: |
139+
echo "Current Directory: $(pwd)"
140+
ls -lah /home/rstudio/.workbench
141+
ls -lah $(pwd)
142+
Rscript -e 'sessionInfo()'
143+
shell: bash
144+
145+
- name: "Mark Repository as Safe"
146+
run: |
147+
git config --global --add safe.directory $(pwd)
148+
shell: bash
149+
150+
- name: "Ensure sandpaper is loadable"
151+
run: |
152+
.libPaths()
153+
library(sandpaper)
154+
shell: Rscript {0}
155+
156+
- name: "Setup Lesson Dependencies"
157+
run: |
158+
Rscript /home/rstudio/.workbench/setup_lesson_deps.R
159+
shell: bash
160+
161+
- name: "Fortify renv Cache"
162+
run: |
163+
Rscript /home/rstudio/.workbench/fortify_renv_cache.R
164+
shell: bash
165+
166+
- name: "Get Container Version Used"
167+
id: wb-vers
168+
uses: carpentries/actions/container-version@main
169+
with:
170+
WORKBENCH_TAG: ${{ vars.WORKBENCH_TAG }}
171+
renv-needed: ${{ needs.check-renv.outputs.renv-needed }}
172+
token: ${{ secrets.GITHUB_TOKEN }}
173+
174+
- name: "Validate Current Org and Workflow"
175+
id: validate-org-workflow
176+
uses: carpentries/actions/validate-org-workflow@main
177+
with:
178+
repo: ${{ github.repository }}
179+
workflow: ${{ github.workflow }}
180+
181+
- name: "Configure AWS credentials via OIDC"
182+
id: aws-creds
183+
env:
184+
role-to-assume: ${{ secrets.AWS_GH_OIDC_ARN }}
185+
aws-region: ${{ secrets.AWS_GH_OIDC_REGION }}
186+
if: |
187+
steps.validate-org-workflow.outputs.is_valid == 'true' &&
188+
env.role-to-assume != '' &&
189+
env.aws-region != ''
190+
uses: aws-actions/configure-aws-credentials@v5.0.0
191+
with:
192+
role-to-assume: ${{ env.role-to-assume }}
193+
aws-region: ${{ env.aws-region }}
194+
output-credentials: true
195+
196+
- name: "Upload cache object to S3"
197+
id: upload-cache
198+
uses: carpentries/actions-cache@frog-matchedkey-1
199+
with:
200+
accessKey: ${{ steps.aws-creds.outputs.aws-access-key-id }}
201+
secretKey: ${{ steps.aws-creds.outputs.aws-secret-access-key }}
202+
sessionToken: ${{ steps.aws-creds.outputs.aws-session-token }}
203+
bucket: workbench-docker-caches
204+
path: |
205+
/home/rstudio/lesson/renv
206+
/usr/local/lib/R/site-library
207+
key: ${{ github.repository }}/${{ steps.wb-vers.outputs.container-version }}_renv-${{ needs.check-renv.outputs.renv-cache-hashsum }}
208+
restore-keys:
209+
${{ github.repository }}/${{ steps.wb-vers.outputs.container-version }}_renv-
210+
211+
record-cache-result:
212+
name: "Record Caching Status"
213+
runs-on: ubuntu-latest
214+
needs: [check-renv, update-renv-cache]
215+
if: always()
216+
env:
217+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
218+
steps:
219+
- name: "Record cache result"
220+
221+
run: |
222+
echo "${{ needs.update-renv-cache.result == 'success' || needs.check-renv.outputs.renv-cache-available == 'true' || 'false' }}" > ${{ github.workspace }}/apply-cache-result
223+
shell: bash
224+
225+
- name: "Upload cache result"
226+
uses: actions/upload-artifact@v4
227+
with:
228+
name: apply-cache-result
229+
path: ${{ github.workspace }}/apply-cache-result
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: "01 Maintain: Build and Deploy Site"
2+
description: "Build and deploy the lesson site using the carpentries/workbench-docker container"
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
paths-ignore:
8+
- '.github/workflows/**.yaml'
9+
- '.github/workbench-docker-version.txt'
10+
schedule:
11+
- cron: '0 0 * * 2'
12+
workflow_run:
13+
workflows: ["03 Maintain: Apply Package Cache"]
14+
types:
15+
- completed
16+
workflow_dispatch:
17+
inputs:
18+
name:
19+
description: 'Who triggered this build?'
20+
required: true
21+
default: 'Maintainer (via GitHub)'
22+
CACHE_VERSION:
23+
description: 'Optional renv cache version override'
24+
required: false
25+
default: ''
26+
reset:
27+
description: 'Reset cached markdown files'
28+
required: true
29+
default: false
30+
type: boolean
31+
force-skip-manage-deps:
32+
description: 'Skip build-time dependency management'
33+
required: true
34+
default: false
35+
type: boolean
36+
37+
# only one build/deploy at a time
38+
concurrency:
39+
group: docker-build-deploy
40+
cancel-in-progress: true
41+
42+
jobs:
43+
preflight:
44+
name: "Preflight: Schedule, Push, or PR?"
45+
runs-on: ubuntu-latest
46+
outputs:
47+
do-build: ${{ steps.build-check.outputs.do-build }}
48+
renv-needed: ${{ steps.build-check.outputs.renv-needed }}
49+
renv-cache-hashsum: ${{ steps.build-check.outputs.renv-cache-hashsum }}
50+
workbench-container-file-exists: ${{ steps.wb-vers.outputs.workbench-container-file-exists }}
51+
wb-vers: ${{ steps.wb-vers.outputs.container-version }}
52+
last-wb-vers: ${{ steps.wb-vers.outputs.last-container-version }}
53+
workbench-update: ${{ steps.wb-vers.outputs.workbench-update }}
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
steps:
57+
- name: "Should we run build and deploy?"
58+
id: build-check
59+
uses: carpentries/actions/build-preflight@main
60+
61+
- name: "Checkout Lesson"
62+
if: steps.build-check.outputs.do-build == 'true'
63+
uses: actions/checkout@v4
64+
65+
- name: "Get container version info"
66+
id: wb-vers
67+
if: steps.build-check.outputs.do-build == 'true'
68+
uses: carpentries/actions/container-version@main
69+
with:
70+
WORKBENCH_TAG: ${{ vars.WORKBENCH_TAG }}
71+
renv-needed: ${{ steps.build-check.outputs.renv-needed }}
72+
token: ${{ secrets.GITHUB_TOKEN }}
73+
74+
full-build:
75+
name: "Build Full Site"
76+
runs-on: ubuntu-latest
77+
needs: preflight
78+
if: |
79+
needs.preflight.outputs.do-build == 'true' &&
80+
needs.preflight.outputs.workbench-update != 'true'
81+
env:
82+
RENV_EXISTS: ${{ needs.preflight.outputs.renv-needed }}
83+
RENV_HASH: ${{ needs.preflight.outputs.renv-cache-hashsum }}
84+
permissions:
85+
checks: write
86+
contents: write
87+
pages: write
88+
id-token: write
89+
container:
90+
image: ghcr.io/carpentries/workbench-docker:${{ vars.WORKBENCH_TAG || 'latest' }}
91+
env:
92+
WORKBENCH_PROFILE: "ci"
93+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
94+
RENV_PATHS_ROOT: /home/rstudio/lesson/renv
95+
RENV_PROFILE: "lesson-requirements"
96+
RENV_CONFIG_EXTERNAL_LIBRARIES: "/usr/local/lib/R/site-library"
97+
volumes:
98+
- ${{ github.workspace }}:/home/rstudio/lesson
99+
options: --cpus 1
100+
steps:
101+
- uses: actions/checkout@v4
102+
103+
- name: "Debugging Info"
104+
run: |
105+
cd /home/rstudio/lesson
106+
echo "Current Directory: $(pwd)"
107+
echo "RENV_HASH is $RENV_HASH"
108+
ls -lah /home/rstudio/.workbench
109+
ls -lah $(pwd)
110+
Rscript -e 'sessionInfo()'
111+
shell: bash
112+
113+
- name: "Mark Repository as Safe"
114+
run: |
115+
git config --global --add safe.directory $(pwd)
116+
shell: bash
117+
118+
- name: "Setup Lesson Dependencies"
119+
id: build-container-deps
120+
uses: carpentries/actions/build-container-deps@main
121+
with:
122+
CACHE_VERSION: ${{ vars.CACHE_VERSION || github.event.inputs.CACHE_VERSION || '' }}
123+
WORKBENCH_TAG: ${{ vars.WORKBENCH_TAG || 'latest' }}
124+
LESSON_PATH: ${{ vars.LESSON_PATH || '/home/rstudio/lesson' }}
125+
role-to-assume: ${{ secrets.AWS_GH_OIDC_ARN }}
126+
aws-region: ${{ secrets.AWS_GH_OIDC_REGION }}
127+
token: ${{ secrets.GITHUB_TOKEN }}
128+
129+
- name: "Run Container and Build Site"
130+
id: build-and-deploy
131+
uses: carpentries/actions/build-and-deploy@main
132+
with:
133+
reset: ${{ vars.BUILD_RESET || github.event.inputs.reset || 'false' }}
134+
skip-manage-deps: ${{ github.event.inputs.force-skip-manage-deps == 'true' || steps.build-container-deps.outputs.renv-cache-available || steps.build-container-deps.outputs.backup-cache-used || 'false' }}
135+
136+
update-container-version:
137+
name: "Update container version used"
138+
runs-on: ubuntu-latest
139+
needs: [preflight]
140+
permissions:
141+
actions: write
142+
contents: write
143+
pull-requests: write
144+
id-token: write
145+
if: |
146+
needs.preflight.outputs.do-build == 'true' &&
147+
(
148+
needs.preflight.outputs.workbench-container-file-exists == 'false' ||
149+
needs.preflight.outputs.workbench-update == 'true'
150+
)
151+
steps:
152+
- name: "Record container version used"
153+
uses: carpentries/actions/record-container-version@main
154+
with:
155+
CONTAINER_VER: ${{ needs.preflight.outputs.wb-vers }}
156+
AUTO_MERGE: ${{ vars.AUTO_MERGE_CONTAINER_VERSION_UPDATE || 'true' }}
157+
token: ${{ secrets.GITHUB_TOKEN }}
158+
role-to-assume: ${{ secrets.AWS_GH_OIDC_ARN }}
159+
aws-region: ${{ secrets.AWS_GH_OIDC_REGION }}

0 commit comments

Comments
 (0)