Skip to content

Commit 5b413ac

Browse files
committed
provenance: set mode max and builder-id for public repos by default
Signed-off-by: CrazyMax <[email protected]>
1 parent 3842cfa commit 5b413ac

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

.github/workflows/ci.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,7 @@ jobs:
529529
file: ./test/go/Dockerfile
530530
target: ${{ matrix.target }}
531531
outputs: ${{ matrix.output }}
532-
attests: |
533-
type=sbom
534-
type=provenance,mode=max,builder-id=https://github.com/${{ env.GITHUB_REPOSITORY }}/actions/runs/${{ env.GITHUB_RUN_ID }}
532+
sbom: true
535533
cache-from: type=gha,scope=attests-${{ matrix.target }}
536534
cache-to: type=gha,scope=attests-${{ matrix.target }},mode=max
537535
-

dist/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

+20
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, context: str
164164
if (buildx.satisfies(buildxVersion, '>=0.10.0')) {
165165
if (inputs.provenance) {
166166
args.push('--provenance', inputs.provenance);
167+
} else if (fromPayload('repository.private') !== false) {
168+
args.push('--provenance', `mode=min,inline-only=true`);
169+
} else {
170+
args.push('--provenance', `mode=max,builder-id=${process.env.GITHUB_SERVER_URL || 'https://github.com'}/${github.context.repo.owner}/${github.context.repo.repo}/actions/runs/${github.context.runId}`);
167171
}
168172
if (inputs.sbom) {
169173
args.push('--sbom', inputs.sbom);
@@ -264,3 +268,19 @@ export const asyncForEach = async (array, callback) => {
264268
await callback(array[index], index, array);
265269
}
266270
};
271+
272+
function fromPayload(path: string): any {
273+
return select(github.context.payload, path);
274+
}
275+
276+
function select(obj: any, path: string): any {
277+
if (!obj) {
278+
return undefined;
279+
}
280+
const i = path.indexOf('.');
281+
if (i < 0) {
282+
return obj[path];
283+
}
284+
const key = path.slice(0, i);
285+
return select(obj[key], path.slice(i + 1));
286+
}

0 commit comments

Comments
 (0)