Skip to content

Commit 96c8196

Browse files
jmeridthKyFaSt
andcommitted
fix: use deploy environment for build job and replace ref with sha to prevent TOCTOU
based on feedback from security folks Signed-off-by: jmeridth <jmeridth@gmail.com> Co-authored-by: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com>
1 parent 901aefb commit 96c8196

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

.github/workflows/jekyll-preview.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ permissions:
1717
# Allow only one concurrent deployment per PR, skipping runs queued between the run in-progress and latest queued.
1818
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
1919
concurrency:
20-
group: 'pages-preview @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
20+
group: "pages-preview @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
2121
cancel-in-progress: false
2222
jobs:
2323
# Build job
2424
build:
25+
environment:
26+
name: "Pages Preview"
2527
# Limit permissions of the GITHUB_TOKEN for untrusted code
2628
permissions:
2729
contents: read
@@ -31,7 +33,7 @@ jobs:
3133
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
3234
with:
3335
# For PRs make sure to checkout the PR branch
34-
ref: ${{ github.event.pull_request.head.ref }}
36+
ref: ${{ github.event.pull_request.head.sha }}
3537
repository: ${{ github.event.pull_request.head.repo.full_name }}
3638
- name: Setup Pages
3739
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
@@ -46,7 +48,7 @@ jobs:
4648
# Deployment job
4749
deploy:
4850
environment:
49-
name: 'Pages Preview'
51+
name: "Pages Preview"
5052
url: ${{ steps.deployment.outputs.page_url }}
5153
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
5254
permissions:
@@ -60,4 +62,4 @@ jobs:
6062
id: deployment
6163
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4
6264
with:
63-
preview: 'true'
65+
preview: "true"

0 commit comments

Comments
 (0)