@@ -169,14 +169,17 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, context: str
169
169
if ( inputs . provenance ) {
170
170
args . push ( '--provenance' , inputs . provenance ) ;
171
171
} else if ( ( await buildx . satisfiesBuildKitVersion ( inputs . builder , '>=0.11.0' , standalone ) ) && ! hasDockerExport ( inputs ) ) {
172
- // If provenance not specified but BuildKit version compatible for
173
- // attestation, disable provenance anyway . Also needs to make sure user
172
+ // if provenance not specified and BuildKit version compatible for
173
+ // attestation, set default provenance . Also needs to make sure user
174
174
// doesn't want to explicitly load the image to docker.
175
- // While this action successfully pushes OCI compliant images to
176
- // well-known registries, some runtimes (e.g. Google Cloud Run and AWS
177
- // Lambda) are not able to pull resulting image from their own registry...
178
- // See also https://github.com/docker/buildx/issues/1533
179
- args . push ( '--provenance' , 'false' ) ;
175
+ if ( fromPayload ( 'repository.private' ) !== false ) {
176
+ // if this is a private repository, we set the default provenance
177
+ // attributes being set in buildx: https://github.com/docker/buildx/blob/fb27e3f919dcbf614d7126b10c2bc2d0b1927eb6/build/build.go#L603
178
+ args . push ( '--provenance' , getProvenanceAttrs ( `mode=min,inline-only=true` ) ) ;
179
+ } else {
180
+ // for a public repository, we set max provenance mode.
181
+ args . push ( '--provenance' , getProvenanceAttrs ( `mode=max` ) ) ;
182
+ }
180
183
}
181
184
if ( inputs . sbom ) {
182
185
args . push ( '--sbom' , inputs . sbom ) ;
@@ -278,6 +281,24 @@ export const asyncForEach = async (array, callback) => {
278
281
}
279
282
} ;
280
283
284
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
285
+ function fromPayload ( path : string ) : any {
286
+ return select ( github . context . payload , path ) ;
287
+ }
288
+
289
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
290
+ function select ( obj : any , path : string ) : any {
291
+ if ( ! obj ) {
292
+ return undefined ;
293
+ }
294
+ const i = path . indexOf ( '.' ) ;
295
+ if ( i < 0 ) {
296
+ return obj [ path ] ;
297
+ }
298
+ const key = path . slice ( 0 , i ) ;
299
+ return select ( obj [ key ] , path . slice ( i + 1 ) ) ;
300
+ }
301
+
281
302
function getProvenanceInput ( name : string ) : string {
282
303
const input = core . getInput ( name ) ;
283
304
if ( ! input ) {
0 commit comments