Skip to content

Commit b6cb15e

Browse files
authored
chore: switch to GitHub attestations (#687)
* chore: only run social-interaction on opened events * chore: switch to GitHub attestations * chore: fix verify step and linter findings * chore: remove provenance from image * docs: added new verification commands
1 parent d48e6ac commit b6cb15e

File tree

5 files changed

+58
-15
lines changed

5 files changed

+58
-15
lines changed

.github/workflows/build-push.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ jobs:
2222
build-push:
2323
runs-on: ubuntu-latest
2424
permissions:
25+
attestations: write
2526
# dependency-submission needs contents write permission.
2627
contents: write
28+
# attest-build-provenance needs id-token write permission.
29+
id-token: write
2730
packages: write
2831
pull-requests: write
29-
# This is used to complete the identity challenge
30-
# with sigstore/fulcio when running outside of PRs.
31-
id-token: write
3232
strategy:
3333
matrix:
3434
flavor: ["cpp", "rust"]
@@ -39,8 +39,6 @@ jobs:
3939
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4040
with:
4141
persist-credentials: false
42-
- uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
43-
if: github.event_name != 'merge_group'
4442
- uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
4543
- uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
4644
if: github.event_name != 'merge_group'
@@ -98,7 +96,6 @@ jobs:
9896
devcontainer.metadata=${{ steps.devcontainer-metadata.outputs.metadata }}
9997
annotations: ${{ steps.metadata.outputs.annotations }}
10098
sbom: true
101-
provenance: true
10299
cache-from: type=gha,scope=${{ github.repository }}-${{ matrix.flavor }}
103100
cache-to: type=gha,mode=max,scope=${{ github.repository }}-${{ matrix.flavor }}
104101
- uses: ./.github/actions/container-size-diff
@@ -121,14 +118,18 @@ jobs:
121118
with:
122119
comment-summary-in-pr: on-failure
123120
fail-on-severity: critical
124-
- name: Sign the images with GitHub OIDC token
121+
- uses: actions/attest-build-provenance@7668571508540a607bdfd90a87a560489fe372eb # v2.1.0
122+
if: github.event_name != 'merge_group'
123+
with:
124+
subject-name: ${{ env.REGISTRY }}/${{ github.repository }}-${{ matrix.flavor }}
125+
subject-digest: ${{ steps.build-and-push.outputs.digest }}
126+
push-to-registry: true
127+
- name: Verify attestation
125128
if: github.event_name != 'merge_group'
126-
# This step uses the GitHub OIDC identity token to provision an ephemeral certificate
127-
# against the sigstore community Fulcio instance.
128129
env:
129-
DIGEST: ${{ steps.build-and-push.outputs.digest }}
130+
GH_TOKEN: ${{ github.token }}
130131
run: |
131-
cosign sign --yes --recursive "${{ env.REGISTRY }}/${{ github.repository }}-${{ matrix.flavor }}@${DIGEST}"
132+
gh attestation verify --repo ${{ github.repository }} oci://${{ env.REGISTRY }}/${{ github.repository }}-${{ matrix.flavor }}@${{ steps.build-and-push.outputs.digest }}
132133
acceptance-test:
133134
if: github.event_name == 'pull_request'
134135
needs: build-push
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Package Published
3+
4+
on:
5+
registry_package:
6+
types: [published]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
attach-provenance-to-release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- run: |
16+
set -Eeuo pipefail
17+
echo "${{ toJson(github.event.registry_package) }}" | jq .
18+
env:
19+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pr-image-cleanup.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ jobs:
2020
permissions:
2121
packages: write
2222
steps:
23-
- uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
2423
- uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
2524
with:
2625
registry: ${{ env.REGISTRY }}
2726
username: ${{ github.actor }}
2827
password: ${{ secrets.GITHUB_TOKEN }}
29-
- run: cosign clean -f --type=signature "${{ env.REGISTRY }}/${{ github.repository }}-${{ matrix.flavor }}:pr-${{ github.event.pull_request.number }}"
3028
- uses: bots-house/ghcr-delete-image-action@3827559c68cb4dcdf54d813ea9853be6d468d3a4 # v1.1.0
3129
with:
3230
owner: ${{ github.repository_owner }}

.github/workflows/social-interaction.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ name: Social Interaction
33

44
on:
55
issues:
6+
types: [opened]
67
pull_request:
8+
types: [opened]
79

810
permissions:
911
contents: read

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Both containers can be used in Visual Studio Code or GitHub Codespaces without a
5353

5454
### Verify image signature
5555

56+
<details><summary>Prior to version 5.6.0</summary>
57+
5658
The container images are signed with [SigStore](https://www.sigstore.dev/) [Cosign](https://docs.sigstore.dev/cosign/signing/overview/) using a keyless signing method.
5759

5860
The signature can be [verified](https://docs.sigstore.dev/cosign/verifying/verify/) with the following command (using Docker), verifying that the image is actually signed by the GitHub CI system:
@@ -69,12 +71,33 @@ docker run --rm gcr.io/projectsigstore/cosign verify ghcr.io/philips-software/am
6971
docker run --rm gcr.io/projectsigstore/cosign verify ghcr.io/philips-software/amp-devcontainer-rust --certificate-oidc-issuer https://token.actions.githubusercontent.com --certificate-identity-regexp https://github.com/philips-software/amp-devcontainer
7072
```
7173

74+
</details>
75+
76+
The container images are signed using the [attest-build-provenance](https://github.com/actions/attest-build-provenance) action.
77+
78+
The attestations can be checked with the following command, verifying that the image is actually built by the GitHub CI system:
79+
80+
> amp-devcontainer-cpp
81+
82+
```sh
83+
gh attestation verify --repo philips-software/amp-devcontainer oci://ghcr.io/philips-software/amp-devcontainer-cpp
84+
```
85+
86+
> amp-devcontainer-rust
87+
88+
```sh
89+
gh attestation verify --repo philips-software/amp-devcontainer oci://ghcr.io/philips-software/amp-devcontainer-rust
90+
```
91+
92+
### Local development
93+
7294
The resulting containers can be used in a `.devcontainer.json` file or in a `.devcontainer` folder.
7395

7496
> [!NOTE]
7597
> While the following examples use the `latest` tag, it is recommended to pin to a specific version. Or better yet, a specific SHA.
98+
> See the [releases](https://github.com/philips-software/amp-devcontainer/releases) for the SHA corresponding to a specific release.
7699
77-
### amp-devcontainer-cpp
100+
#### amp-devcontainer-cpp
78101

79102
> .devcontainer/devcontainer.json or .devcontainer.json
80103
@@ -84,7 +107,7 @@ The resulting containers can be used in a `.devcontainer.json` file or in a `.de
84107
}
85108
```
86109

87-
### amp-devcontainer-rust
110+
#### amp-devcontainer-rust
88111

89112
> .devcontainer/devcontainer.json or .devcontainer.json
90113

0 commit comments

Comments
 (0)