Skip to content

Commit 329ca27

Browse files
committed
Update workflows: fix gh calls, general logic improvements
1 parent 98754a3 commit 329ca27

5 files changed

Lines changed: 93 additions & 67 deletions

File tree

.github/workflows/docker_apply_cache.yaml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
name: "Check If We Need {renv}"
3636
runs-on: ubuntu-latest
3737
needs: preflight
38-
if: ${{ needs.preflight.outputs.do-apply == 'true' }}
38+
if: needs.preflight.outputs.do-apply == 'true'
3939
permissions:
4040
id-token: write # OIDC permission required
4141
outputs:
@@ -55,7 +55,7 @@ jobs:
5555
name: "No renv cache used"
5656
runs-on: ubuntu-latest
5757
needs: check-renv
58-
if: ${{ needs.check-renv.outputs.renv-needed != 'true' }}
58+
if: needs.check-renv.outputs.renv-needed != 'true'
5959
steps:
6060
- name: "No renv cache needed"
6161
run: echo "No renv cache needed for this lesson"
@@ -64,7 +64,7 @@ jobs:
6464
name: "renv cache available"
6565
runs-on: ubuntu-latest
6666
needs: check-renv
67-
if: ${{ needs.check-renv.outputs.renv-cache-available == 'true' }}
67+
if: needs.check-renv.outputs.renv-cache-available == 'true'
6868
steps:
6969
- name: "renv cache available"
7070
run: echo "renv cache available for this lesson"
@@ -106,14 +106,14 @@ jobs:
106106
steps:
107107
- uses: actions/checkout@v4
108108

109-
- name: Debugging Info
109+
- name: "Debugging Info"
110110
run: |
111111
echo "Current Directory: $(pwd)"
112112
ls -lah /home/rstudio/.workbench
113113
ls -lah $(pwd)
114114
Rscript -e 'sessionInfo()'
115115
116-
- name: Mark Repository as Safe
116+
- name: "Mark Repository as Safe"
117117
run: |
118118
git config --global --add safe.directory $(pwd)
119119
@@ -123,15 +123,15 @@ jobs:
123123
library(sandpaper)
124124
shell: Rscript {0}
125125

126-
- name: Setup Lesson Dependencies
126+
- name: "Setup Lesson Dependencies"
127127
run: |
128128
Rscript /home/rstudio/.workbench/setup_lesson_deps.R
129129
130-
- name: Fortify renv Cache
130+
- name: "Fortify renv Cache"
131131
run: |
132132
Rscript /home/rstudio/.workbench/fortify_renv_cache.R
133133
134-
- name: Get Container Version Used
134+
- name: "Get Container Version Used"
135135
id: wb-vers
136136
uses: carpentries/actions/container-version@frog-s3-test-1
137137
with:
@@ -145,16 +145,16 @@ jobs:
145145
repo: ${{ github.repository }}
146146
workflow: ${{ github.workflow }}
147147

148-
- name: Configure AWS credentials via OIDC
148+
- name: "Configure AWS credentials via OIDC"
149149
id: aws-creds
150-
if: ${{ steps.validate-org-workflow.outputs.is_valid == 'true' }}
150+
if: steps.validate-org-workflow.outputs.is_valid == 'true'
151151
uses: aws-actions/configure-aws-credentials@v5.0.0
152152
with:
153153
role-to-assume: ${{ secrets.AWS_GH_OIDC_ARN }}
154154
aws-region: ${{ secrets.AWS_GH_OIDC_REGION }}
155155
output-credentials: true
156156

157-
- name: Upload cache object to S3
157+
- name: "Upload cache object to S3"
158158
uses: carpentries/actions-cache@frog-matchedkey-1
159159
with:
160160
# insecure: false # optional, use http instead of https. default false
@@ -174,8 +174,7 @@ jobs:
174174
name: "Trigger Build and Deploy Workflow"
175175
runs-on: ubuntu-latest
176176
needs: [check-renv, update-renv-cache]
177-
if: |
178-
needs.update-renv-cache.outcome == 'success'
177+
if: needs.update-renv-cache.outcome == 'success'
179178
steps:
180179
- name: "Trigger Build and Deploy Workflow"
181180
env:

.github/workflows/docker_build_deploy.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ jobs:
5050
id: build-check
5151
uses: carpentries/actions/build-preflight@frog-s3-test-1
5252

53-
- name: Checkout Lesson
54-
if: ${{ steps.build-check.outputs.do-build == 'true' }}
53+
- name: "Checkout Lesson"
54+
if: steps.build-check.outputs.do-build == 'true'
5555
uses: actions/checkout@v4
5656

57-
- name: Get container version info
57+
- name: "Get container version info"
5858
id: wb-vers
59-
if: ${{ steps.build-check.outputs.do-build == 'true' }}
59+
if: steps.build-check.outputs.do-build == 'true'
6060
uses: carpentries/actions/container-version@frog-s3-test-1
6161
with:
6262
WORKBENCH_TAG: ${{ vars.WORKBENCH_TAG }}
@@ -66,7 +66,10 @@ jobs:
6666
name: "Build Full Site"
6767
runs-on: ubuntu-latest
6868
needs: preflight
69-
if: always() && ${{ needs.preflight.outputs.do-build == 'true' && needs.preflight.outputs.workbench-update != 'true' }}
69+
if: |
70+
always() &&
71+
needs.preflight.outputs.do-build == 'true' &&
72+
needs.preflight.outputs.workbench-update != 'true'
7073
env:
7174
RENV_EXISTS: ${{ needs.preflight.outputs.renv-needed }}
7275
RENV_HASH: ${{ needs.preflight.outputs.renv-cache-hashsum }}
@@ -112,7 +115,7 @@ jobs:
112115
role-to-assume: ${{ secrets.AWS_GH_OIDC_ARN }}
113116
aws-region: ${{ secrets.AWS_GH_OIDC_REGION }}
114117

115-
- name: Run Container and Build Site
118+
- name: "Run Container and Build Site"
116119
id: build-and-deploy
117120
uses: carpentries/actions/build-and-deploy@frog-s3-test-1
118121
with:
@@ -122,7 +125,7 @@ jobs:
122125
update-container-version:
123126
name: "Update container version used"
124127
runs-on: ubuntu-latest
125-
needs: [preflight, full-build]
128+
needs: [preflight]
126129
permissions:
127130
contents: write
128131
pull-requests: write
@@ -131,13 +134,10 @@ jobs:
131134
needs.preflight.outputs.do-build == 'true' &&
132135
(
133136
needs.preflight.outputs.workbench-container-file-exists == 'false' ||
134-
(
135-
needs.full-build.build-and-deploy.outcome == 'success' &&
136-
needs.preflight.outputs.wb-vers != needs.preflight.outputs.last-wb-vers
137-
)
137+
needs.preflight.outputs.workbench-update == 'true'
138138
)
139139
steps:
140-
- name: Record container version used
140+
- name: "Record container version used"
141141
uses: carpentries/actions/record-container-version@frog-s3-test-1
142142
with:
143143
CONTAINER_VER: ${{ needs.preflight.outputs.wb-vers }}

.github/workflows/docker_pr_receive.yaml

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
pr_branch: ${{ env.PR_BRANCH }}
5151
steps:
5252
- name: "Auto: Grab PR"
53-
if: ${{ github.event_name == 'pull_request' }}
53+
if: github.event_name == 'pull_request'
5454
env:
5555
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5656
run: |
@@ -116,13 +116,14 @@ jobs:
116116
- test-pr
117117
- check-renv
118118
runs-on: ubuntu-latest
119-
if: ${{ needs.test-pr.outputs.is_valid == 'true' }}
119+
if: needs.test-pr.outputs.is_valid == 'true'
120120
env:
121121
CHIVE: ${{ github.workspace }}/site/chive
122122
PR: ${{ github.workspace }}/site/pr
123123
GHWMD: ${{ github.workspace }}/site/built
124124
PR_BRANCH: ${{ needs.test-pr.outputs.pr_branch }}
125125
PR_NUMBER: ${{ needs.test-pr.outputs.pr_number }}
126+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126127
permissions:
127128
checks: write
128129
contents: write
@@ -133,17 +134,17 @@ jobs:
133134
env:
134135
WORKBENCH_PROFILE: "ci"
135136
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
137+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136138
RENV_PATHS_ROOT: /home/rstudio/lesson/renv
137139
RENV_PROFILE: "lesson-requirements"
138140
RENV_CONFIG_EXTERNAL_LIBRARIES: "/usr/local/lib/R/site-library"
139141
volumes:
140142
- ${{ github.workspace }}:/home/rstudio/lesson
141143
options: --cpus 2
144+
outputs:
145+
workbench-update: ${{ steps.wb-vers.outputs.workbench-update }}
142146
steps:
143-
- name: "Check Out PR Branch"
144-
uses: actions/checkout@v4
145-
# with:
146-
# ref: ${{ env.PR_BRANCH }}
147+
- uses: actions/checkout@v4
147148

148149
- name: "Check Out Staging Branch"
149150
uses: actions/checkout@v4
@@ -168,23 +169,25 @@ jobs:
168169
169170
- name: Get Container Version Used
170171
id: wb-vers
171-
if: ${{ needs.check-renv.outputs.renv-needed == 'true' }}
172+
if: needs.check-renv.outputs.renv-needed == 'true'
172173
uses: carpentries/actions/container-version@frog-s3-test-1
173174
with:
174175
WORKBENCH_TAG: ${{ vars.WORKBENCH_TAG }}
175176
renv-needed: ${{ needs.check-renv.outputs.renv-needed }}
176177

177178
- name: "Validate Current Org and Workflow"
178179
id: validate-org-workflow
179-
if: ${{ needs.check-renv.outputs.renv-needed == 'true' }}
180+
if: needs.check-renv.outputs.renv-needed == 'true'
180181
uses: carpentries/actions/validate-org-workflow@frog-s3-test-1
181182
with:
182183
repo: ${{ github.repository }}
183184
workflow: ${{ github.workflow }}
184185

185186
- name: Configure AWS credentials via OIDC
186187
id: aws-creds
187-
if: ${{ steps.validate-org-workflow.outputs.is_valid == 'true' && needs.check-renv.outputs.renv-needed == 'true' }}
188+
if: |
189+
steps.validate-org-workflow.outputs.is_valid == 'true' &&
190+
needs.check-renv.outputs.renv-needed == 'true'
188191
uses: aws-actions/configure-aws-credentials@v5.0.0
189192
with:
190193
role-to-assume: ${{ secrets.AWS_GH_OIDC_ARN }}
@@ -194,7 +197,7 @@ jobs:
194197
- name: Get cache object from S3
195198
id: s3-cache
196199
uses: carpentries/actions-cache@frog-matchedkey-1
197-
if: ${{ needs.check-renv.outputs.renv-needed == 'true' }}
200+
if: needs.check-renv.outputs.renv-needed == 'true'
198201
with:
199202
# insecure: false # optional, use http instead of https. default false
200203
accessKey: ${{ steps.aws-creds.outputs.aws-access-key-id }}
@@ -209,7 +212,9 @@ jobs:
209212
${{ github.repository }}/${{ steps.wb-vers.outputs.container-version }}_renv-
210213

211214
- name: "Fortify renv Cache"
212-
if: ${{ needs.check-renv.outputs.renv-needed == 'true' && steps.s3-cache.outputs.cache-hit != 'true'}}
215+
if: |
216+
needs.check-renv.outputs.renv-needed == 'true' &&
217+
steps.s3-cache.outputs.cache-hit != 'true'
213218
run: |
214219
Rscript /home/rstudio/.workbench/fortify_renv_cache.R
215220
@@ -260,12 +265,12 @@ jobs:
260265
shell: Rscript {0}
261266

262267
pr-checks:
263-
name: "Trigger PR Checks"
268+
name: "Trigger PR Checks?"
264269
needs:
265270
- test-pr
266271
- build-md-source
267272
runs-on: ubuntu-latest
268-
if: ${{ needs.test-pr.outputs.is_valid == 'true' }}
273+
if: needs.test-pr.outputs.is_valid == 'true'
269274
permissions:
270275
actions: write
271276
checks: write
@@ -279,3 +284,24 @@ jobs:
279284
run: |
280285
gh workflow run pr-comment.yaml --ref main --field workflow_id=${{ github.run_id }}
281286
shell: bash
287+
288+
cache-update:
289+
name: "Trigger Update Cache Workflow?"
290+
needs:
291+
- check-renv
292+
- build-md-source
293+
runs-on: ubuntu-latest
294+
if: |
295+
needs.check-renv.outputs.renv-needed == 'true' &&
296+
needs.build-md-source.outputs.workbench-update == 'true' &&
297+
needs.build-md-source.build-site.outcome == 'success'
298+
permissions:
299+
actions: write
300+
checks: write
301+
steps:
302+
- name: "Trigger renv rebuild"
303+
env:
304+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
305+
run: |
306+
gh workflow run update-cache.yaml
307+
shell: bash

0 commit comments

Comments
 (0)