mirror of
https://github.com/edera-dev/sprout.git
synced 2026-11-04 19:52:22 +00:00
fix(ci): don't give pull request builds attestation permissions
The publish job ran for pull requests with contents: write, id-token: write, and attestations: write, while running build code from the pull request. None of these were needed there: uploading artifacts doesn't need contents: write, and attestation was already skipped for pull requests. Build with read-only permissions, and attest in a separate job that only runs on pushes to main.
This commit is contained in:
1 parent
5b10fe9576
commit
cf1ea65414
1 file changed
+20
-5
@@ -19,10 +19,10 @@ jobs:
|
|||||||
artifacts:
|
artifacts:
|
||||||
name: artifacts
|
name: artifacts
|
||||||
permissions:
|
permissions:
|
||||||
contents: write # Needed to upload artifacts.
|
contents: read # Needed to checkout the repository.
|
||||||
id-token: write # Needed for attestation.
|
|
||||||
attestations: write # Needed for attestations.
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
artifact-digest: "${{ steps.upload.outputs.artifact-digest }}"
|
||||||
steps:
|
steps:
|
||||||
- name: harden runner
|
- name: harden runner
|
||||||
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
|
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
|
||||||
@@ -48,9 +48,24 @@ jobs:
|
|||||||
name: artifacts
|
name: artifacts
|
||||||
path: target/assemble/*
|
path: target/assemble/*
|
||||||
|
|
||||||
|
# Attestation runs in its own job so that pull requests, which run the build with
|
||||||
|
# code from the pull request, never get the permissions needed to attest.
|
||||||
|
attest:
|
||||||
|
name: attest
|
||||||
|
needs: artifacts
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
permissions:
|
||||||
|
id-token: write # Needed for attestation.
|
||||||
|
attestations: write # Needed for attestations.
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: harden runner
|
||||||
|
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
|
||||||
|
with:
|
||||||
|
egress-policy: audit
|
||||||
|
|
||||||
- name: 'attest artifacts'
|
- name: 'attest artifacts'
|
||||||
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
|
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
|
||||||
with:
|
with:
|
||||||
subject-name: artifacts.zip
|
subject-name: artifacts.zip
|
||||||
subject-digest: "sha256:${{ steps.upload.outputs.artifact-digest }}"
|
subject-digest: "sha256:${{ needs.artifacts.outputs.artifact-digest }}"
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
Reference in new issue
Block a user