Skip to content

Commit 1a9b983

Browse files
committed
add attestation-id and attestation-url outputs
Signed-off-by: Brian DeHamer <[email protected]>
1 parent 65e34a8 commit 1a9b983

File tree

5 files changed

+42
-11
lines changed

5 files changed

+42
-11
lines changed

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ attest:
4444
1. Add the following to your workflow after your artifact has been built:
4545

4646
```yaml
47-
- uses: actions/attest@v1
47+
- uses: actions/attest@v2
4848
with:
4949
subject-path: '<PATH TO ARTIFACT>'
5050
predicate-type: '<PREDICATE URI>'
@@ -61,7 +61,7 @@ attest:
6161
See [action.yml](action.yml)
6262

6363
```yaml
64-
- uses: actions/attest@v1
64+
- uses: actions/attest@v2
6565
with:
6666
# Path to the artifact serving as the subject of the attestation. Must
6767
# specify exactly one of "subject-path" or "subject-digest". May contain
@@ -109,9 +109,11 @@ See [action.yml](action.yml)
109109

110110
<!-- markdownlint-disable MD013 -->
111111

112-
| Name | Description | Example |
113-
| ------------- | -------------------------------------------------------------- | ----------------------- |
114-
| `bundle-path` | Absolute path to the file containing the generated attestation | `/tmp/attestation.json` |
112+
| Name | Description | Example |
113+
| ----------------- | -------------------------------------------------------------- | ------------------------------------------------ |
114+
| `attestation-id` | GitHub ID for the attestation | `123456` |
115+
| `attestation-url` | Absolute path to the file containing the generated attestation | `https://github.com/foo/bar/attestations/123456` |
116+
| `bundle-path` | Absolute path to the file containing the generated attestation | `/tmp/attestation.json` |
115117

116118
<!-- markdownlint-enable MD013 -->
117119

@@ -157,7 +159,7 @@ jobs:
157159
- name: Build artifact
158160
run: make my-app
159161
- name: Attest
160-
uses: actions/attest@v1
162+
uses: actions/attest@v2
161163
with:
162164
subject-path: '${{ github.workspace }}/my-app'
163165
predicate-type: 'https://example.com/predicate/v1'
@@ -170,7 +172,7 @@ If you are generating multiple artifacts, you can attest all of them at the same
170172
time by using a wildcard in the `subject-path` input.
171173

172174
```yaml
173-
- uses: actions/attest@v1
175+
- uses: actions/attest@v2
174176
with:
175177
subject-path: 'dist/**/my-bin-*'
176178
predicate-type: 'https://example.com/predicate/v1'
@@ -184,13 +186,13 @@ Alternatively, you can explicitly list multiple subjects with either a comma or
184186
newline delimited list:
185187

186188
```yaml
187-
- uses: actions/attest@v1
189+
- uses: actions/attest@v2
188190
with:
189191
subject-path: 'dist/foo, dist/bar'
190192
```
191193

192194
```yaml
193-
- uses: actions/attest@v1
195+
- uses: actions/attest@v2
194196
with:
195197
subject-path: |
196198
dist/foo
@@ -247,7 +249,7 @@ jobs:
247249
push: true
248250
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
249251
- name: Attest
250-
uses: actions/attest@v1
252+
uses: actions/attest@v2
251253
id: attest
252254
with:
253255
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

__tests__/main.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,16 @@ describe('action', () => {
199199
'bundle-path',
200200
expect.stringMatching('attestation.json')
201201
)
202+
expect(setOutputMock).toHaveBeenNthCalledWith(
203+
2,
204+
'attestation-id',
205+
expect.stringMatching(attestationID)
206+
)
207+
expect(setOutputMock).toHaveBeenNthCalledWith(
208+
3,
209+
'attestation-url',
210+
expect.stringContaining(`foo/bar/attestations/${attestationID}`)
211+
)
202212
expect(setFailedMock).not.toHaveBeenCalled()
203213
})
204214
})
@@ -285,6 +295,16 @@ describe('action', () => {
285295
'bundle-path',
286296
expect.stringMatching('attestation.json')
287297
)
298+
expect(setOutputMock).toHaveBeenNthCalledWith(
299+
2,
300+
'attestation-id',
301+
expect.stringMatching(attestationID)
302+
)
303+
expect(setOutputMock).toHaveBeenNthCalledWith(
304+
3,
305+
'attestation-url',
306+
expect.stringContaining(`foo/bar/attestations/${attestationID}`)
307+
)
288308
expect(setFailedMock).not.toHaveBeenCalled()
289309
})
290310
})

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ inputs:
6161
outputs:
6262
bundle-path:
6363
description: 'The path to the file containing the attestation bundle.'
64+
attestation-id:
65+
description: 'The ID of the attestation.'
66+
attestation-url:
67+
description: 'The URL for the attestation summary.'
6468

6569
runs:
6670
using: node20

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "actions/attest",
33
"description": "Generate signed attestations for workflow artifacts",
4-
"version": "2.0.1",
4+
"version": "2.1.0",
55
"author": "",
66
"private": true,
77
"homepage": "https://github.com/actions/attest",

src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ export async function run(inputs: RunInputs): Promise<void> {
7979
flag: 'a'
8080
})
8181

82+
if (att.attestationID) {
83+
core.setOutput('attestation-id', att.attestationID)
84+
core.setOutput('attestation-url', attestationURL(att.attestationID))
85+
}
86+
8287
if (inputs.showSummary) {
8388
logSummary(att)
8489
}

0 commit comments

Comments
 (0)