Compare commits
	
		
			45 Commits
		
	
	
		
			v5.3.0
			...
			releases/v
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | ca052bb54a | ||
|   | 025c2051f3 | ||
|   | 12076d2fb1 | ||
|   | ef6cba3353 | ||
|   | 4c16cf906a | ||
|   | a3118a86c8 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | c86eb8b0f7 | ||
|   | 2a53c6ccda | ||
|   | ccef1f210d | ||
|   | 79117b6ea5 | ||
|   | df19a799eb | ||
|   | 0e2ab16cd2 | ||
|   | 54d0f58d64 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 563a2f55e4 | ||
|   | 6003d3266a | ||
|   | e1e22cdde8 | ||
|   | fc15b64049 | ||
|   | 6c58ea3670 | ||
|   | 729f7f4926 | ||
|   | 99d83235bc | ||
|   | 1d5307d7af | ||
|   | cf8d130912 | ||
|   | 8804d8e2ac | ||
|   | 1984549052 | ||
|   | 5bc9e2e9b9 | ||
|   | eb539f44b1 | ||
|   | b6ff9e5753 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 929fba6cce | ||
|   | 7f1f43ba33 | ||
|   | 40d6a900e0 | ||
|   | d56be63626 | ||
|   | eb3cfeaf00 | ||
|   | d0fc12d8a4 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 68615d5b67 | ||
|   | c3b570184c | ||
|   | 7e6f77677b | ||
|   | 2ce6beaad4 | ||
|   | 4c8d1e6826 | ||
|   | b0312962ef | ||
|   | 96acf63e4c | ||
|   | f8bc7f4600 | ||
|   | c2064be02c | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 4f02f34098 | ||
|   | 090ca155fc | ||
|   | ec4854f780 | 
| @@ -1,2 +1,12 @@ | |||||||
| /coverage | /coverage | ||||||
| /node_modules |  | ||||||
|  | # Dependency directories | ||||||
|  | node_modules/ | ||||||
|  | jspm_packages/ | ||||||
|  |  | ||||||
|  | # yarn v2 | ||||||
|  | .yarn/cache | ||||||
|  | .yarn/unplugged | ||||||
|  | .yarn/build-state.yml | ||||||
|  | .yarn/install-state.gz | ||||||
|  | .pnp.* | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ | |||||||
|   ], |   ], | ||||||
|   "parser": "@typescript-eslint/parser", |   "parser": "@typescript-eslint/parser", | ||||||
|   "parserOptions": { |   "parserOptions": { | ||||||
|     "ecmaVersion": "latest", |     "ecmaVersion": 2023, | ||||||
|     "sourceType": "module" |     "sourceType": "module" | ||||||
|   }, |   }, | ||||||
|   "plugins": [ |   "plugins": [ | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							| @@ -1,2 +1,4 @@ | |||||||
|  | /.yarn/releases/** binary | ||||||
|  | /.yarn/plugins/** binary | ||||||
| /dist/** linguist-generated=true | /dist/** linguist-generated=true | ||||||
| /lib/** linguist-generated=true | /lib/** linguist-generated=true | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								.github/workflows/.e2e-run.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/.e2e-run.yml
									
									
									
									
										vendored
									
									
								
							| @@ -94,7 +94,7 @@ jobs: | |||||||
|         uses: docker/setup-buildx-action@v3 |         uses: docker/setup-buildx-action@v3 | ||||||
|         with: |         with: | ||||||
|           version: ${{ matrix.buildx_version }} |           version: ${{ matrix.buildx_version }} | ||||||
|           config: /tmp/buildkitd.toml |           buildkitd-config: /tmp/buildkitd.toml | ||||||
|           buildkitd-flags: --debug --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host |           buildkitd-flags: --debug --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host | ||||||
|           driver-opts: | |           driver-opts: | | ||||||
|             image=${{ matrix.buildkit_image }} |             image=${{ matrix.buildkit_image }} | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							| @@ -1274,10 +1274,9 @@ jobs: | |||||||
|         uses: docker/setup-buildx-action@v3 |         uses: docker/setup-buildx-action@v3 | ||||||
|         with: |         with: | ||||||
|           version: ${{ inputs.buildx-version || env.BUILDX_VERSION }} |           version: ${{ inputs.buildx-version || env.BUILDX_VERSION }} | ||||||
|           # TODO: use buildx-stable-1 image when v0.13 promoted |  | ||||||
|           driver-opts: | |           driver-opts: | | ||||||
|             network=host |             network=host | ||||||
|             image=moby/buildkit:v0.13.0 |             image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }} | ||||||
|           buildkitd-flags: --debug |           buildkitd-flags: --debug | ||||||
|       - |       - | ||||||
|         name: Build |         name: Build | ||||||
| @@ -1324,10 +1323,9 @@ jobs: | |||||||
|         uses: docker/setup-buildx-action@v3 |         uses: docker/setup-buildx-action@v3 | ||||||
|         with: |         with: | ||||||
|           version: ${{ inputs.buildx-version || env.BUILDX_VERSION }} |           version: ${{ inputs.buildx-version || env.BUILDX_VERSION }} | ||||||
|           # TODO: use buildx-stable-1 image when v0.13 promoted |  | ||||||
|           driver-opts: | |           driver-opts: | | ||||||
|             network=host |             network=host | ||||||
|             image=moby/buildkit:v0.13.0 |             image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }} | ||||||
|           buildkitd-flags: --debug |           buildkitd-flags: --debug | ||||||
|       - |       - | ||||||
|         name: Build |         name: Build | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								.github/workflows/e2e.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								.github/workflows/e2e.yml
									
									
									
									
										vendored
									
									
								
							| @@ -88,13 +88,13 @@ jobs: | |||||||
|             username_secret: QUAY_USERNAME |             username_secret: QUAY_USERNAME | ||||||
|             password_secret: QUAY_TOKEN |             password_secret: QUAY_TOKEN | ||||||
|             type: remote |             type: remote | ||||||
| #          - |           - | ||||||
| #            name: Artifactory |             name: Artifactory | ||||||
| #            registry: sforzando-build-team-local.jfrog.io |             registry: infradock.jfrog.io | ||||||
| #            slug: sforzando-build-team-local.jfrog.io/build-push-action-e2e |             slug: infradock.jfrog.io/test-ghaction/build-push-action | ||||||
| #            username_secret: ARTIFACTORY_USERNAME |             username_secret: ARTIFACTORY_USERNAME | ||||||
| #            password_secret: ARTIFACTORY_TOKEN |             password_secret: ARTIFACTORY_TOKEN | ||||||
| #            type: remote |             type: remote | ||||||
|           - |           - | ||||||
|             name: Harbor |             name: Harbor | ||||||
|             id: harbor |             id: harbor | ||||||
|   | |||||||
							
								
								
									
										66
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										66
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,7 +1,5 @@ | |||||||
| node_modules | # https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore | ||||||
| lib |  | ||||||
|  |  | ||||||
| # Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore |  | ||||||
| # Logs | # Logs | ||||||
| logs | logs | ||||||
| *.log | *.log | ||||||
| @@ -9,6 +7,7 @@ npm-debug.log* | |||||||
| yarn-debug.log* | yarn-debug.log* | ||||||
| yarn-error.log* | yarn-error.log* | ||||||
| lerna-debug.log* | lerna-debug.log* | ||||||
|  | .pnpm-debug.log* | ||||||
|  |  | ||||||
| # Diagnostic reports (https://nodejs.org/api/report.html) | # Diagnostic reports (https://nodejs.org/api/report.html) | ||||||
| report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||||||
| @@ -19,34 +18,14 @@ pids | |||||||
| *.seed | *.seed | ||||||
| *.pid.lock | *.pid.lock | ||||||
|  |  | ||||||
| # Directory for instrumented libs generated by jscoverage/JSCover |  | ||||||
| lib-cov |  | ||||||
|  |  | ||||||
| # Coverage directory used by tools like istanbul | # Coverage directory used by tools like istanbul | ||||||
| coverage | coverage | ||||||
| *.lcov | *.lcov | ||||||
|  |  | ||||||
| # nyc test coverage |  | ||||||
| .nyc_output |  | ||||||
|  |  | ||||||
| # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) |  | ||||||
| .grunt |  | ||||||
|  |  | ||||||
| # Bower dependency directory (https://bower.io/) |  | ||||||
| bower_components |  | ||||||
|  |  | ||||||
| # node-waf configuration |  | ||||||
| .lock-wscript |  | ||||||
|  |  | ||||||
| # Compiled binary addons (https://nodejs.org/api/addons.html) |  | ||||||
| build/Release |  | ||||||
|  |  | ||||||
| # Dependency directories | # Dependency directories | ||||||
|  | node_modules/ | ||||||
| jspm_packages/ | jspm_packages/ | ||||||
|  |  | ||||||
| # TypeScript v1 declaration files |  | ||||||
| typings/ |  | ||||||
|  |  | ||||||
| # TypeScript cache | # TypeScript cache | ||||||
| *.tsbuildinfo | *.tsbuildinfo | ||||||
|  |  | ||||||
| @@ -56,36 +35,19 @@ typings/ | |||||||
| # Optional eslint cache | # Optional eslint cache | ||||||
| .eslintcache | .eslintcache | ||||||
|  |  | ||||||
| # Optional REPL history |  | ||||||
| .node_repl_history |  | ||||||
|  |  | ||||||
| # Output of 'npm pack' |  | ||||||
| *.tgz |  | ||||||
|  |  | ||||||
| # Yarn Integrity file | # Yarn Integrity file | ||||||
| .yarn-integrity | .yarn-integrity | ||||||
|  |  | ||||||
| # dotenv environment variables file | # dotenv environment variable files | ||||||
| .env | .env | ||||||
| .env.test | .env.development.local | ||||||
|  | .env.test.local | ||||||
|  | .env.production.local | ||||||
|  | .env.local | ||||||
|  |  | ||||||
| # parcel-bundler cache (https://parceljs.org/) | # yarn v2 | ||||||
| .cache | .yarn/cache | ||||||
|  | .yarn/unplugged | ||||||
| # next.js build output | .yarn/build-state.yml | ||||||
| .next | .yarn/install-state.gz | ||||||
|  | .pnp.* | ||||||
| # nuxt.js build output |  | ||||||
| .nuxt |  | ||||||
|  |  | ||||||
| # vuepress build output |  | ||||||
| .vuepress/dist |  | ||||||
|  |  | ||||||
| # Serverless directories |  | ||||||
| .serverless/ |  | ||||||
|  |  | ||||||
| # FuseBox cache |  | ||||||
| .fusebox/ |  | ||||||
|  |  | ||||||
| # DynamoDB Local files |  | ||||||
| .dynamodb/ |  | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								.prettierignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.prettierignore
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | |||||||
|  | # Dependency directories | ||||||
|  | node_modules/ | ||||||
|  | jspm_packages/ | ||||||
|  |  | ||||||
|  | # yarn v2 | ||||||
|  | .yarn/ | ||||||
							
								
								
									
										541
									
								
								.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										541
									
								
								.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										13
									
								
								.yarnrc.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								.yarnrc.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | |||||||
|  | logFilters: | ||||||
|  |   - code: YN0013 | ||||||
|  |     level: discard | ||||||
|  |   - code: YN0019 | ||||||
|  |     level: discard | ||||||
|  |   - code: YN0076 | ||||||
|  |     level: discard | ||||||
|  |  | ||||||
|  | nodeLinker: node-modules | ||||||
|  |  | ||||||
|  | plugins: | ||||||
|  |   - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs | ||||||
|  |     spec: "@yarnpkg/plugin-interactive-tools" | ||||||
							
								
								
									
										20
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								README.md
									
									
									
									
									
								
							| @@ -31,6 +31,9 @@ ___ | |||||||
|   * [Named contexts](https://docs.docker.com/build/ci/github-actions/named-contexts/) |   * [Named contexts](https://docs.docker.com/build/ci/github-actions/named-contexts/) | ||||||
|   * [Copy image between registries](https://docs.docker.com/build/ci/github-actions/copy-image-registries/) |   * [Copy image between registries](https://docs.docker.com/build/ci/github-actions/copy-image-registries/) | ||||||
|   * [Update Docker Hub repo description](https://docs.docker.com/build/ci/github-actions/update-dockerhub-desc/) |   * [Update Docker Hub repo description](https://docs.docker.com/build/ci/github-actions/update-dockerhub-desc/) | ||||||
|  |   * [SBOM and provenance attestations](https://docs.docker.com/build/ci/github-actions/attestations/) | ||||||
|  |   * [Annotations](https://docs.docker.com/build/ci/github-actions/annotations/) | ||||||
|  |   * [Reproducible builds](https://docs.docker.com/build/ci/github-actions/reproducible-builds/) | ||||||
| * [Customizing](#customizing) | * [Customizing](#customizing) | ||||||
|   * [inputs](#inputs) |   * [inputs](#inputs) | ||||||
|   * [outputs](#outputs) |   * [outputs](#outputs) | ||||||
| @@ -118,14 +121,6 @@ to the default Git context: | |||||||
|           tags: user/app:latest |           tags: user/app:latest | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| > **Warning** |  | ||||||
| > |  | ||||||
| > Subdirectory for Git context is available from [BuildKit v0.9.0](https://github.com/moby/buildkit/releases/tag/v0.9.0). |  | ||||||
| > If you're using the `docker` builder (default if `setup-buildx-action` not used), |  | ||||||
| > then BuildKit in Docker Engine will be used. As Docker Engine < v22.x.x embeds |  | ||||||
| > Buildkit 0.8.2 at the moment, it does not support this feature. It's therefore |  | ||||||
| > required to use the `setup-buildx-action` at the moment. |  | ||||||
|  |  | ||||||
| Building from the current repository automatically uses the [GitHub Token](https://docs.github.com/en/actions/security-guides/automatic-token-authentication), | Building from the current repository automatically uses the [GitHub Token](https://docs.github.com/en/actions/security-guides/automatic-token-authentication), | ||||||
| so it does not need to be passed. If you want to authenticate against another | so it does not need to be passed. If you want to authenticate against another | ||||||
| private repository, you have to use a [secret](https://docs.docker.com/build/ci/github-actions/secrets) | private repository, you have to use a [secret](https://docs.docker.com/build/ci/github-actions/secrets) | ||||||
| @@ -194,6 +189,9 @@ jobs: | |||||||
| * [Named contexts](https://docs.docker.com/build/ci/github-actions/named-contexts/) | * [Named contexts](https://docs.docker.com/build/ci/github-actions/named-contexts/) | ||||||
| * [Copy image between registries](https://docs.docker.com/build/ci/github-actions/copy-image-registries/) | * [Copy image between registries](https://docs.docker.com/build/ci/github-actions/copy-image-registries/) | ||||||
| * [Update Docker Hub repo description](https://docs.docker.com/build/ci/github-actions/update-dockerhub-desc/) | * [Update Docker Hub repo description](https://docs.docker.com/build/ci/github-actions/update-dockerhub-desc/) | ||||||
|  | * [SBOM and provenance attestations](https://docs.docker.com/build/ci/github-actions/attestations/) | ||||||
|  | * [Annotations](https://docs.docker.com/build/ci/github-actions/annotations/) | ||||||
|  | * [Reproducible builds](https://docs.docker.com/build/ci/github-actions/reproducible-builds/) | ||||||
|  |  | ||||||
| ## Customizing | ## Customizing | ||||||
|  |  | ||||||
| @@ -232,7 +230,7 @@ Following inputs can be used as `step.with` keys | |||||||
| | `network`          | String      | Set the networking mode for the `RUN` instructions during build                                                                                                                   | | | `network`          | String      | Set the networking mode for the `RUN` instructions during build                                                                                                                   | | ||||||
| | `no-cache`         | Bool        | Do not use cache when building the image (default `false`)                                                                                                                        | | | `no-cache`         | Bool        | Do not use cache when building the image (default `false`)                                                                                                                        | | ||||||
| | `no-cache-filters` | List/CSV    | Do not cache specified stages                                                                                                                                                     | | | `no-cache-filters` | List/CSV    | Do not cache specified stages                                                                                                                                                     | | ||||||
| | `outputs`¹         | List        | List of [output destinations](https://docs.docker.com/engine/reference/commandline/buildx_build/#output) (format: `type=local,dest=path`)                                         | | | `outputs`          | List        | List of [output destinations](https://docs.docker.com/engine/reference/commandline/buildx_build/#output) (format: `type=local,dest=path`)                                         | | ||||||
| | `platforms`        | List/CSV    | List of [target platforms](https://docs.docker.com/engine/reference/commandline/buildx_build/#platform) for build                                                                 | | | `platforms`        | List/CSV    | List of [target platforms](https://docs.docker.com/engine/reference/commandline/buildx_build/#platform) for build                                                                 | | ||||||
| | `provenance`       | Bool/String | Generate [provenance](https://docs.docker.com/build/attestations/slsa-provenance/) attestation for the build (shorthand for `--attest=type=provenance`)                           | | | `provenance`       | Bool/String | Generate [provenance](https://docs.docker.com/build/attestations/slsa-provenance/) attestation for the build (shorthand for `--attest=type=provenance`)                           | | ||||||
| | `pull`             | Bool        | Always attempt to pull all referenced images (default `false`)                                                                                                                    | | | `pull`             | Bool        | Always attempt to pull all referenced images (default `false`)                                                                                                                    | | ||||||
| @@ -248,10 +246,6 @@ Following inputs can be used as `step.with` keys | |||||||
| | `ulimit`           | List        | [Ulimit](https://docs.docker.com/engine/reference/commandline/buildx_build/#ulimit) options (e.g., `nofile=1024:1024`)                                                            | | | `ulimit`           | List        | [Ulimit](https://docs.docker.com/engine/reference/commandline/buildx_build/#ulimit) options (e.g., `nofile=1024:1024`)                                                            | | ||||||
| | `github-token`     | String      | GitHub Token used to authenticate against a repository for [Git context](#git-context) (default `${{ github.token }}`)                                                            | | | `github-token`     | String      | GitHub Token used to authenticate against a repository for [Git context](#git-context) (default `${{ github.token }}`)                                                            | | ||||||
|  |  | ||||||
| > **Note** |  | ||||||
| > |  | ||||||
| > * ¹ multiple `outputs` are [not yet supported](https://github.com/moby/buildkit/issues/1555) |  | ||||||
|  |  | ||||||
| ### outputs | ### outputs | ||||||
|  |  | ||||||
| The following outputs are available: | The following outputs are available: | ||||||
|   | |||||||
| @@ -1,13 +1,16 @@ | |||||||
| import {beforeEach, describe, expect, jest, test} from '@jest/globals'; | import {beforeEach, describe, expect, jest, test} from '@jest/globals'; | ||||||
| import * as fs from 'fs'; | import * as fs from 'fs'; | ||||||
| import * as path from 'path'; | import * as path from 'path'; | ||||||
|  |  | ||||||
| import {Builder} from '@docker/actions-toolkit/lib/buildx/builder'; | import {Builder} from '@docker/actions-toolkit/lib/buildx/builder'; | ||||||
| import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx'; | import {Buildx} from '@docker/actions-toolkit/lib/buildx/buildx'; | ||||||
|  | import {Build} from '@docker/actions-toolkit/lib/buildx/build'; | ||||||
| import {Context} from '@docker/actions-toolkit/lib/context'; | import {Context} from '@docker/actions-toolkit/lib/context'; | ||||||
| import {Docker} from '@docker/actions-toolkit/lib/docker/docker'; | import {Docker} from '@docker/actions-toolkit/lib/docker/docker'; | ||||||
| import {GitHub} from '@docker/actions-toolkit/lib/github'; | import {GitHub} from '@docker/actions-toolkit/lib/github'; | ||||||
| import {Toolkit} from '@docker/actions-toolkit/lib/toolkit'; | import {Toolkit} from '@docker/actions-toolkit/lib/toolkit'; | ||||||
| import {BuilderInfo} from '@docker/actions-toolkit/lib/types/builder'; |  | ||||||
|  | import {BuilderInfo} from '@docker/actions-toolkit/lib/types/buildx/builder'; | ||||||
| import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github'; | import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github'; | ||||||
|  |  | ||||||
| import * as context from '../src/context'; | import * as context from '../src/context'; | ||||||
| @@ -35,6 +38,16 @@ jest.spyOn(Docker, 'isAvailable').mockImplementation(async (): Promise<boolean> | |||||||
|   return true; |   return true; | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | const metadataJson = path.join(tmpDir, 'metadata.json'); | ||||||
|  | jest.spyOn(Build.prototype, 'getMetadataFilePath').mockImplementation((): string => { | ||||||
|  |   return metadataJson; | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | const imageIDFilePath = path.join(tmpDir, 'iidfile.txt'); | ||||||
|  | jest.spyOn(Build.prototype, 'getImageIDFilePath').mockImplementation((): string => { | ||||||
|  |   return imageIDFilePath; | ||||||
|  | }); | ||||||
|  |  | ||||||
| jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => { | jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<BuilderInfo> => { | ||||||
|   return { |   return { | ||||||
|     name: 'builder2', |     name: 'builder2', | ||||||
| @@ -78,7 +91,7 @@ describe('getArgs', () => { | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -101,7 +114,7 @@ ccc"`], | |||||||
|         '--build-arg', 'MY_ARG=val1,val2,val3', |         '--build-arg', 'MY_ARG=val1,val2,val3', | ||||||
|         '--build-arg', 'ARG=val', |         '--build-arg', 'ARG=val', | ||||||
|         '--build-arg', `MULTILINE=aaaa\nbbbb\nccc`, |         '--build-arg', `MULTILINE=aaaa\nbbbb\nccc`, | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         'https://github.com/docker/build-push-action.git#refs/heads/master' |         'https://github.com/docker/build-push-action.git#refs/heads/master' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -117,7 +130,7 @@ ccc"`], | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--tag', 'name/app:7.4', |         '--tag', 'name/app:7.4', | ||||||
|         '--tag', 'name/app:latest', |         '--tag', 'name/app:latest', | ||||||
|         'https://github.com/docker/build-push-action.git#refs/heads/master' |         'https://github.com/docker/build-push-action.git#refs/heads/master' | ||||||
| @@ -172,7 +185,7 @@ ccc"`], | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -189,7 +202,7 @@ ccc"`], | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, |         '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
| @@ -230,7 +243,7 @@ ccc"`], | |||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--file', './test/Dockerfile', |         '--file', './test/Dockerfile', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--platform', 'linux/amd64,linux/arm64', |         '--platform', 'linux/amd64,linux/arm64', | ||||||
|         '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, |         '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, | ||||||
|         '--builder', 'builder-git-context-2', |         '--builder', 'builder-git-context-2', | ||||||
| @@ -264,7 +277,7 @@ ccc"`], | |||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--file', './test/Dockerfile', |         '--file', './test/Dockerfile', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--platform', 'linux/amd64,linux/arm64', |         '--platform', 'linux/amd64,linux/arm64', | ||||||
|         '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, |         '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, | ||||||
|         '--secret', `id=MYSECRET,src=${tmpName}`, |         '--secret', `id=MYSECRET,src=${tmpName}`, | ||||||
| @@ -301,7 +314,7 @@ ccc`], | |||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--file', './test/Dockerfile', |         '--file', './test/Dockerfile', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--platform', 'linux/amd64,linux/arm64', |         '--platform', 'linux/amd64,linux/arm64', | ||||||
|         '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, |         '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, | ||||||
|         '--secret', `id=MYSECRET,src=${tmpName}`, |         '--secret', `id=MYSECRET,src=${tmpName}`, | ||||||
| @@ -330,7 +343,7 @@ ccc`], | |||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--file', './test/Dockerfile', |         '--file', './test/Dockerfile', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--secret', `id=MY_SECRET,src=${tmpName}`, |         '--secret', `id=MY_SECRET,src=${tmpName}`, | ||||||
|         '--builder', 'builder-git-context-2', |         '--builder', 'builder-git-context-2', | ||||||
|         '--network', 'host', |         '--network', 'host', | ||||||
| @@ -377,8 +390,8 @@ ccc`], | |||||||
|         '--add-host', 'docker:10.180.0.1', |         '--add-host', 'docker:10.180.0.1', | ||||||
|         '--add-host', 'foo:10.0.0.1', |         '--add-host', 'foo:10.0.0.1', | ||||||
|         '--file', './test/Dockerfile', |         '--file', './test/Dockerfile', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '--network', 'host', |         '--network', 'host', | ||||||
|         '--push', |         '--push', | ||||||
|         '.' |         '.' | ||||||
| @@ -406,11 +419,11 @@ nproc=3`], | |||||||
|         '--add-host', 'foo:10.0.0.1', |         '--add-host', 'foo:10.0.0.1', | ||||||
|         '--cgroup-parent', 'foo', |         '--cgroup-parent', 'foo', | ||||||
|         '--file', './test/Dockerfile', |         '--file', './test/Dockerfile', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--shm-size', '2g', |         '--shm-size', '2g', | ||||||
|         '--ulimit', 'nofile=1024:1024', |         '--ulimit', 'nofile=1024:1024', | ||||||
|         '--ulimit', 'nproc=3', |         '--ulimit', 'nproc=3', | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -426,8 +439,8 @@ nproc=3`], | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         'https://github.com/docker/build-push-action.git#refs/heads/master:docker' |         'https://github.com/docker/build-push-action.git#refs/heads/master:docker' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -444,9 +457,9 @@ nproc=3`], | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, |         '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         'https://github.com/docker/build-push-action.git#refs/heads/master:subdir' |         'https://github.com/docker/build-push-action.git#refs/heads/master:subdir' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -463,8 +476,8 @@ nproc=3`], | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -480,9 +493,9 @@ nproc=3`], | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         "--provenance", `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, |         '--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -499,9 +512,9 @@ nproc=3`], | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         "--provenance", `builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, |         '--attest', `type=provenance,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -518,9 +531,9 @@ nproc=3`], | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         "--provenance", `mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, |         '--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -537,9 +550,9 @@ nproc=3`], | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         "--provenance", 'false', |         '--attest', 'type=provenance,disabled=true', | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -556,9 +569,9 @@ nproc=3`], | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         "--provenance", 'builder-id=foo', |         '--attest', 'type=provenance,builder-id=foo', | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -575,9 +588,9 @@ nproc=3`], | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         "--output", 'type=docker', |         "--output", 'type=docker', | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -593,9 +606,9 @@ nproc=3`], | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--load', |         '--load', | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
| @@ -613,14 +626,14 @@ nproc=3`], | |||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--build-arg', 'FOO=bar#baz', |         '--build-arg', 'FOO=bar#baz', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--load', |         '--load', | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
|     [ |     [ | ||||||
|       25, |       26, | ||||||
|       '0.10.0', |       '0.10.0', | ||||||
|       new Map<string, string>([ |       new Map<string, string>([ | ||||||
|         ['context', '.'], |         ['context', '.'], | ||||||
| @@ -635,14 +648,14 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`] | |||||||
|         'build', |         'build', | ||||||
|         '--secret', 'id=MY_SECRET,env=MY_SECRET_ENV', |         '--secret', 'id=MY_SECRET,env=MY_SECRET_ENV', | ||||||
|         '--secret', 'id=ANOTHER_SECRET,env=ANOTHER_SECRET_ENV', |         '--secret', 'id=ANOTHER_SECRET,env=ANOTHER_SECRET_ENV', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--load', |         '--load', | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
|     [ |     [ | ||||||
|       26, |       27, | ||||||
|       '0.10.0', |       '0.10.0', | ||||||
|       new Map<string, string>([ |       new Map<string, string>([ | ||||||
|         ['context', '.'], |         ['context', '.'], | ||||||
| @@ -656,14 +669,14 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`] | |||||||
|         'build', |         'build', | ||||||
|         '--secret', 'id=MY_SECRET,env=MY_SECRET_ENV', |         '--secret', 'id=MY_SECRET,env=MY_SECRET_ENV', | ||||||
|         '--secret', 'id=ANOTHER_SECRET,env=ANOTHER_SECRET_ENV', |         '--secret', 'id=ANOTHER_SECRET,env=ANOTHER_SECRET_ENV', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         '--load', |         '--load', | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
|     [ |     [ | ||||||
|       27, |       28, | ||||||
|       '0.11.0', |       '0.11.0', | ||||||
|       new Map<string, string>([ |       new Map<string, string>([ | ||||||
|         ['context', '.'], |         ['context', '.'], | ||||||
| @@ -677,13 +690,13 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`] | |||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--output', 'type=local,dest=./release-out', |         '--output', 'type=local,dest=./release-out', | ||||||
|         "--provenance", `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, |         '--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
|     [ |     [ | ||||||
|       28, |       29, | ||||||
|       '0.12.0', |       '0.12.0', | ||||||
|       new Map<string, string>([ |       new Map<string, string>([ | ||||||
|         ['context', '.'], |         ['context', '.'], | ||||||
| @@ -701,13 +714,13 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`] | |||||||
|         '--annotation', 'manifest:example3=yyy', |         '--annotation', 'manifest:example3=yyy', | ||||||
|         '--annotation', 'manifest-descriptor[linux/amd64]:example4=zzz', |         '--annotation', 'manifest-descriptor[linux/amd64]:example4=zzz', | ||||||
|         '--output', 'type=local,dest=./release-out', |         '--output', 'type=local,dest=./release-out', | ||||||
|         "--provenance", `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, |         '--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ], |     ], | ||||||
|     [ |     [ | ||||||
|       29, |       30, | ||||||
|       '0.12.0', |       '0.12.0', | ||||||
|       new Map<string, string>([ |       new Map<string, string>([ | ||||||
|         ['context', '.'], |         ['context', '.'], | ||||||
| @@ -719,13 +732,73 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`] | |||||||
|       ]), |       ]), | ||||||
|       [ |       [ | ||||||
|         'build', |         'build', | ||||||
|         '--iidfile', path.join(tmpDir, 'iidfile'), |         '--iidfile', imageIDFilePath, | ||||||
|         "--output", `type=image,"name=localhost:5000/name/app:latest,localhost:5000/name/app:foo",push-by-digest=true,name-canonical=true,push=true`, |         "--output", `type=image,"name=localhost:5000/name/app:latest,localhost:5000/name/app:foo",push-by-digest=true,name-canonical=true,push=true`, | ||||||
|         "--provenance", `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, |         '--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, | ||||||
|         '--metadata-file', path.join(tmpDir, 'metadata-file'), |         '--metadata-file', metadataJson, | ||||||
|         '.' |         '.' | ||||||
|       ] |       ] | ||||||
|     ] |     ], | ||||||
|  |     [ | ||||||
|  |       31, | ||||||
|  |       '0.13.1', | ||||||
|  |       new Map<string, string>([ | ||||||
|  |         ['context', '.'], | ||||||
|  |         ['load', 'false'], | ||||||
|  |         ['no-cache', 'false'], | ||||||
|  |         ['push', 'false'], | ||||||
|  |         ['pull', 'false'], | ||||||
|  |         ['provenance', 'mode=max'], | ||||||
|  |         ['sbom', 'true'], | ||||||
|  |       ]), | ||||||
|  |       [ | ||||||
|  |         'build', | ||||||
|  |         '--iidfile', imageIDFilePath, | ||||||
|  |         '--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, | ||||||
|  |         '--attest', `type=sbom,disabled=false`, | ||||||
|  |         '--metadata-file', metadataJson, | ||||||
|  |         '.' | ||||||
|  |       ] | ||||||
|  |     ], | ||||||
|  |     [ | ||||||
|  |       32, | ||||||
|  |       '0.13.1', | ||||||
|  |       new Map<string, string>([ | ||||||
|  |         ['context', '.'], | ||||||
|  |         ['load', 'false'], | ||||||
|  |         ['no-cache', 'false'], | ||||||
|  |         ['push', 'false'], | ||||||
|  |         ['pull', 'false'], | ||||||
|  |         ['attests', 'type=provenance,mode=min'], | ||||||
|  |         ['provenance', 'mode=max'], | ||||||
|  |       ]), | ||||||
|  |       [ | ||||||
|  |         'build', | ||||||
|  |         '--iidfile', imageIDFilePath, | ||||||
|  |         '--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, | ||||||
|  |         '--metadata-file', metadataJson, | ||||||
|  |         '.' | ||||||
|  |       ] | ||||||
|  |     ], | ||||||
|  |     [ | ||||||
|  |       33, | ||||||
|  |       '0.13.1', | ||||||
|  |       new Map<string, string>([ | ||||||
|  |         ['context', '.'], | ||||||
|  |         ['load', 'false'], | ||||||
|  |         ['no-cache', 'false'], | ||||||
|  |         ['push', 'false'], | ||||||
|  |         ['pull', 'false'], | ||||||
|  |         ['attests', 'type=provenance,mode=min'], | ||||||
|  |       ]), | ||||||
|  |       [ | ||||||
|  |         'build', | ||||||
|  |         '--iidfile', imageIDFilePath, | ||||||
|  |         '--attest', `type=provenance,mode=min,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789`, | ||||||
|  |         '--metadata-file', metadataJson, | ||||||
|  |         '.' | ||||||
|  |       ] | ||||||
|  |     ], | ||||||
|   ])( |   ])( | ||||||
|     '[%d] given %p with %p as inputs, returns %p', |     '[%d] given %p with %p as inputs, returns %p', | ||||||
|     async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => { |     async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => { | ||||||
|   | |||||||
| @@ -5,9 +5,16 @@ ARG NODE_VERSION=20 | |||||||
| FROM node:${NODE_VERSION}-alpine AS base | FROM node:${NODE_VERSION}-alpine AS base | ||||||
| RUN apk add --no-cache cpio findutils git | RUN apk add --no-cache cpio findutils git | ||||||
| WORKDIR /src | WORKDIR /src | ||||||
|  | RUN --mount=type=bind,target=.,rw \ | ||||||
|  |   --mount=type=cache,target=/src/.yarn/cache <<EOT | ||||||
|  |   corepack enable | ||||||
|  |   yarn --version | ||||||
|  |   yarn config set --home enableTelemetry 0 | ||||||
|  | EOT | ||||||
|  |  | ||||||
| FROM base AS deps | FROM base AS deps | ||||||
| RUN --mount=type=bind,target=.,rw \ | RUN --mount=type=bind,target=.,rw \ | ||||||
|  |   --mount=type=cache,target=/src/.yarn/cache \ | ||||||
|   --mount=type=cache,target=/src/node_modules \ |   --mount=type=cache,target=/src/node_modules \ | ||||||
|   yarn install && mkdir /vendor && cp yarn.lock /vendor |   yarn install && mkdir /vendor && cp yarn.lock /vendor | ||||||
|  |  | ||||||
| @@ -16,18 +23,19 @@ COPY --from=deps /vendor / | |||||||
|  |  | ||||||
| FROM deps AS vendor-validate | FROM deps AS vendor-validate | ||||||
| RUN --mount=type=bind,target=.,rw <<EOT | RUN --mount=type=bind,target=.,rw <<EOT | ||||||
| set -e |   set -e | ||||||
| git add -A |   git add -A | ||||||
| cp -rf /vendor/* . |   cp -rf /vendor/* . | ||||||
| if [ -n "$(git status --porcelain -- yarn.lock)" ]; then |   if [ -n "$(git status --porcelain -- yarn.lock)" ]; then | ||||||
|   echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"' |     echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"' | ||||||
|   git status --porcelain -- yarn.lock |     git status --porcelain -- yarn.lock | ||||||
|   exit 1 |     exit 1 | ||||||
| fi |   fi | ||||||
| EOT | EOT | ||||||
|  |  | ||||||
| FROM deps AS build | FROM deps AS build | ||||||
| RUN --mount=type=bind,target=.,rw \ | RUN --mount=type=bind,target=.,rw \ | ||||||
|  |   --mount=type=cache,target=/src/.yarn/cache \ | ||||||
|   --mount=type=cache,target=/src/node_modules \ |   --mount=type=cache,target=/src/node_modules \ | ||||||
|   yarn run build && mkdir /out && cp -Rf dist /out/ |   yarn run build && mkdir /out && cp -Rf dist /out/ | ||||||
|  |  | ||||||
| @@ -36,32 +44,35 @@ COPY --from=build /out / | |||||||
|  |  | ||||||
| FROM build AS build-validate | FROM build AS build-validate | ||||||
| RUN --mount=type=bind,target=.,rw <<EOT | RUN --mount=type=bind,target=.,rw <<EOT | ||||||
| set -e |   set -e | ||||||
| git add -A |   git add -A | ||||||
| cp -rf /out/* . |   cp -rf /out/* . | ||||||
| if [ -n "$(git status --porcelain -- dist)" ]; then |   if [ -n "$(git status --porcelain -- dist)" ]; then | ||||||
|   echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"' |     echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"' | ||||||
|   git status --porcelain -- dist |     git status --porcelain -- dist | ||||||
|   exit 1 |     exit 1 | ||||||
| fi |   fi | ||||||
| EOT | EOT | ||||||
|  |  | ||||||
| FROM deps AS format | FROM deps AS format | ||||||
| RUN --mount=type=bind,target=.,rw \ | RUN --mount=type=bind,target=.,rw \ | ||||||
|  |   --mount=type=cache,target=/src/.yarn/cache \ | ||||||
|   --mount=type=cache,target=/src/node_modules \ |   --mount=type=cache,target=/src/node_modules \ | ||||||
|   yarn run format \ |   yarn run format \ | ||||||
|   && mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out |   && mkdir /out && find . -name '*.ts' -not -path './node_modules/*' -not -path './.yarn/*' | cpio -pdm /out | ||||||
|  |  | ||||||
| FROM scratch AS format-update | FROM scratch AS format-update | ||||||
| COPY --from=format /out / | COPY --from=format /out / | ||||||
|  |  | ||||||
| FROM deps AS lint | FROM deps AS lint | ||||||
| RUN --mount=type=bind,target=.,rw \ | RUN --mount=type=bind,target=.,rw \ | ||||||
|  |   --mount=type=cache,target=/src/.yarn/cache \ | ||||||
|   --mount=type=cache,target=/src/node_modules \ |   --mount=type=cache,target=/src/node_modules \ | ||||||
|   yarn run lint |   yarn run lint | ||||||
|  |  | ||||||
| FROM deps AS test | FROM deps AS test | ||||||
| RUN --mount=type=bind,target=.,rw \ | RUN --mount=type=bind,target=.,rw \ | ||||||
|  |   --mount=type=cache,target=/src/.yarn/cache \ | ||||||
|   --mount=type=cache,target=/src/node_modules \ |   --mount=type=cache,target=/src/node_modules \ | ||||||
|   yarn run test --coverage --coverageDirectory=/tmp/coverage |   yarn run test --coverage --coverageDirectory=/tmp/coverage | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										86
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										86
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								dist/index.js.map
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/index.js.map
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2045
									
								
								dist/licenses.txt
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2045
									
								
								dist/licenses.txt
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -3,7 +3,7 @@ group "default" { | |||||||
| } | } | ||||||
|  |  | ||||||
| group "pre-checkin" { | group "pre-checkin" { | ||||||
|   targets = ["vendor-update", "format", "build"] |   targets = ["vendor", "format", "build"] | ||||||
| } | } | ||||||
|  |  | ||||||
| group "validate" { | group "validate" { | ||||||
| @@ -34,7 +34,7 @@ target "lint" { | |||||||
|   output = ["type=cacheonly"] |   output = ["type=cacheonly"] | ||||||
| } | } | ||||||
|  |  | ||||||
| target "vendor-update" { | target "vendor" { | ||||||
|   dockerfile = "dev.Dockerfile" |   dockerfile = "dev.Dockerfile" | ||||||
|   target = "vendor-update" |   target = "vendor-update" | ||||||
|   output = ["."] |   output = ["."] | ||||||
|   | |||||||
| @@ -1,3 +0,0 @@ | |||||||
| # Cache |  | ||||||
|  |  | ||||||
| This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/cache/) |  | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| # Copy images between registries |  | ||||||
|  |  | ||||||
| This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/copy-image-registries/) |  | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| # Update Docker Hub repo description |  | ||||||
|  |  | ||||||
| This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/update-dockerhub-desc/) |  | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| # Export image to Docker |  | ||||||
|  |  | ||||||
| This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/export-docker/) |  | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| # Isolated builders |  | ||||||
|  |  | ||||||
| This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/configure-builder/#isolated-builders) |  | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| # Local registry |  | ||||||
|  |  | ||||||
| This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/local-registry/) |  | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| # Multi-platform image |  | ||||||
|  |  | ||||||
| This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/multi-platform/) |  | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| # Named contexts |  | ||||||
|  |  | ||||||
| This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/named-contexts/) |  | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| # Push to multi-registries |  | ||||||
|  |  | ||||||
| This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/push-multi-registries/) |  | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| # Secrets |  | ||||||
|  |  | ||||||
| This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/secrets/) |  | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| # Share built image between jobs |  | ||||||
|  |  | ||||||
| This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/share-image-jobs/) |  | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| # Handle tags and labels |  | ||||||
|  |  | ||||||
| This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/manage-tags-labels/) |  | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| # Test your image before pushing it |  | ||||||
|  |  | ||||||
| This page has moved to [Docker Docs website](https://docs.docker.com/build/ci/github-actions/test-before-push/) |  | ||||||
							
								
								
									
										37
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								package.json
									
									
									
									
									
								
							| @@ -1,17 +1,16 @@ | |||||||
| { | { | ||||||
|   "name": "docker-build-push", |   "name": "docker-build-push", | ||||||
|   "description": "Build and push Docker images", |   "description": "Build and push Docker images", | ||||||
|   "main": "lib/main.js", |   "main": "src/main.ts", | ||||||
|   "scripts": { |   "scripts": { | ||||||
|     "build": "ncc build src/main.ts --source-map --minify --license licenses.txt", |     "build": "ncc build --source-map --minify --license licenses.txt", | ||||||
|     "lint": "yarn run prettier && yarn run eslint", |     "lint": "yarn run prettier && yarn run eslint", | ||||||
|     "format": "yarn run prettier:fix && yarn run eslint:fix", |     "format": "yarn run prettier:fix && yarn run eslint:fix", | ||||||
|     "eslint": "eslint --max-warnings=0 .", |     "eslint": "eslint --max-warnings=0 .", | ||||||
|     "eslint:fix": "eslint --fix .", |     "eslint:fix": "eslint --fix .", | ||||||
|     "prettier": "prettier --check \"./**/*.ts\"", |     "prettier": "prettier --check \"./**/*.ts\"", | ||||||
|     "prettier:fix": "prettier --write \"./**/*.ts\"", |     "prettier:fix": "prettier --write \"./**/*.ts\"", | ||||||
|     "test": "jest", |     "test": "jest" | ||||||
|     "all": "yarn run build && yarn run format && yarn test" |  | ||||||
|   }, |   }, | ||||||
|   "repository": { |   "repository": { | ||||||
|     "type": "git", |     "type": "git", | ||||||
| @@ -25,25 +24,25 @@ | |||||||
|   ], |   ], | ||||||
|   "author": "Docker Inc.", |   "author": "Docker Inc.", | ||||||
|   "license": "Apache-2.0", |   "license": "Apache-2.0", | ||||||
|  |   "packageManager": "yarn@3.6.3", | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@actions/core": "^1.10.1", |     "@actions/core": "^1.10.1", | ||||||
|     "@docker/actions-toolkit": "0.19.0", |     "@docker/actions-toolkit": "0.24.0", | ||||||
|     "handlebars": "^4.7.7" |     "handlebars": "^4.7.7" | ||||||
|   }, |   }, | ||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "@types/csv-parse": "^1.2.2", |     "@types/node": "^20.12.12", | ||||||
|     "@types/node": "^20.5.9", |     "@typescript-eslint/eslint-plugin": "^7.9.0", | ||||||
|     "@typescript-eslint/eslint-plugin": "^6.6.0", |     "@typescript-eslint/parser": "^7.9.0", | ||||||
|     "@typescript-eslint/parser": "^6.6.0", |     "@vercel/ncc": "^0.38.1", | ||||||
|     "@vercel/ncc": "^0.38.0", |     "eslint": "^8.57.0", | ||||||
|     "eslint": "^8.48.0", |     "eslint-config-prettier": "^9.1.0", | ||||||
|     "eslint-config-prettier": "^9.0.0", |     "eslint-plugin-jest": "^28.5.0", | ||||||
|     "eslint-plugin-jest": "^27.2.3", |     "eslint-plugin-prettier": "^5.1.3", | ||||||
|     "eslint-plugin-prettier": "^5.0.0", |     "jest": "^29.7.0", | ||||||
|     "jest": "^29.6.4", |     "prettier": "^3.2.5", | ||||||
|     "prettier": "^3.0.3", |     "ts-jest": "^29.1.2", | ||||||
|     "ts-jest": "^29.1.1", |     "ts-node": "^10.9.2", | ||||||
|     "ts-node": "^10.9.1", |     "typescript": "^5.4.5" | ||||||
|     "typescript": "^5.2.2" |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										176
									
								
								src/context.ts
									
									
									
									
									
								
							
							
						
						
									
										176
									
								
								src/context.ts
									
									
									
									
									
								
							| @@ -1,29 +1,30 @@ | |||||||
| import * as core from '@actions/core'; | import * as core from '@actions/core'; | ||||||
| import * as handlebars from 'handlebars'; | import * as handlebars from 'handlebars'; | ||||||
|  |  | ||||||
|  | import {Build} from '@docker/actions-toolkit/lib/buildx/build'; | ||||||
| import {Context} from '@docker/actions-toolkit/lib/context'; | import {Context} from '@docker/actions-toolkit/lib/context'; | ||||||
| import {GitHub} from '@docker/actions-toolkit/lib/github'; | import {GitHub} from '@docker/actions-toolkit/lib/github'; | ||||||
| import {Inputs as BuildxInputs} from '@docker/actions-toolkit/lib/buildx/inputs'; |  | ||||||
| import {Toolkit} from '@docker/actions-toolkit/lib/toolkit'; | import {Toolkit} from '@docker/actions-toolkit/lib/toolkit'; | ||||||
| import {Util} from '@docker/actions-toolkit/lib/util'; | import {Util} from '@docker/actions-toolkit/lib/util'; | ||||||
|  |  | ||||||
| export interface Inputs { | export interface Inputs { | ||||||
|   addHosts: string[]; |   'add-hosts': string[]; | ||||||
|   allow: string[]; |   allow: string[]; | ||||||
|   annotations: string[]; |   annotations: string[]; | ||||||
|   attests: string[]; |   attests: string[]; | ||||||
|   buildArgs: string[]; |   'build-args': string[]; | ||||||
|   buildContexts: string[]; |   'build-contexts': string[]; | ||||||
|   builder: string; |   builder: string; | ||||||
|   cacheFrom: string[]; |   'cache-from': string[]; | ||||||
|   cacheTo: string[]; |   'cache-to': string[]; | ||||||
|   cgroupParent: string; |   'cgroup-parent': string; | ||||||
|   context: string; |   context: string; | ||||||
|   file: string; |   file: string; | ||||||
|   labels: string[]; |   labels: string[]; | ||||||
|   load: boolean; |   load: boolean; | ||||||
|   network: string; |   network: string; | ||||||
|   noCache: boolean; |   'no-cache': boolean; | ||||||
|   noCacheFilters: string[]; |   'no-cache-filters': string[]; | ||||||
|   outputs: string[]; |   outputs: string[]; | ||||||
|   platforms: string[]; |   platforms: string[]; | ||||||
|   provenance: string; |   provenance: string; | ||||||
| @@ -31,50 +32,50 @@ export interface Inputs { | |||||||
|   push: boolean; |   push: boolean; | ||||||
|   sbom: string; |   sbom: string; | ||||||
|   secrets: string[]; |   secrets: string[]; | ||||||
|   secretEnvs: string[]; |   'secret-envs': string[]; | ||||||
|   secretFiles: string[]; |   'secret-files': string[]; | ||||||
|   shmSize: string; |   'shm-size': string; | ||||||
|   ssh: string[]; |   ssh: string[]; | ||||||
|   tags: string[]; |   tags: string[]; | ||||||
|   target: string; |   target: string; | ||||||
|   ulimit: string[]; |   ulimit: string[]; | ||||||
|   githubToken: string; |   'github-token': string; | ||||||
| } | } | ||||||
|  |  | ||||||
| export async function getInputs(): Promise<Inputs> { | export async function getInputs(): Promise<Inputs> { | ||||||
|   return { |   return { | ||||||
|     addHosts: Util.getInputList('add-hosts'), |     'add-hosts': Util.getInputList('add-hosts'), | ||||||
|     allow: Util.getInputList('allow'), |     allow: Util.getInputList('allow'), | ||||||
|     annotations: Util.getInputList('annotations', {ignoreComma: true}), |     annotations: Util.getInputList('annotations', {ignoreComma: true}), | ||||||
|     attests: Util.getInputList('attests', {ignoreComma: true}), |     attests: Util.getInputList('attests', {ignoreComma: true}), | ||||||
|     buildArgs: Util.getInputList('build-args', {ignoreComma: true}), |     'build-args': Util.getInputList('build-args', {ignoreComma: true}), | ||||||
|     buildContexts: Util.getInputList('build-contexts', {ignoreComma: true}), |     'build-contexts': Util.getInputList('build-contexts', {ignoreComma: true}), | ||||||
|     builder: core.getInput('builder'), |     builder: core.getInput('builder'), | ||||||
|     cacheFrom: Util.getInputList('cache-from', {ignoreComma: true}), |     'cache-from': Util.getInputList('cache-from', {ignoreComma: true}), | ||||||
|     cacheTo: Util.getInputList('cache-to', {ignoreComma: true}), |     'cache-to': Util.getInputList('cache-to', {ignoreComma: true}), | ||||||
|     cgroupParent: core.getInput('cgroup-parent'), |     'cgroup-parent': core.getInput('cgroup-parent'), | ||||||
|     context: core.getInput('context') || Context.gitContext(), |     context: core.getInput('context') || Context.gitContext(), | ||||||
|     file: core.getInput('file'), |     file: core.getInput('file'), | ||||||
|     labels: Util.getInputList('labels', {ignoreComma: true}), |     labels: Util.getInputList('labels', {ignoreComma: true}), | ||||||
|     load: core.getBooleanInput('load'), |     load: core.getBooleanInput('load'), | ||||||
|     network: core.getInput('network'), |     network: core.getInput('network'), | ||||||
|     noCache: core.getBooleanInput('no-cache'), |     'no-cache': core.getBooleanInput('no-cache'), | ||||||
|     noCacheFilters: Util.getInputList('no-cache-filters'), |     'no-cache-filters': Util.getInputList('no-cache-filters'), | ||||||
|     outputs: Util.getInputList('outputs', {ignoreComma: true, quote: false}), |     outputs: Util.getInputList('outputs', {ignoreComma: true, quote: false}), | ||||||
|     platforms: Util.getInputList('platforms'), |     platforms: Util.getInputList('platforms'), | ||||||
|     provenance: BuildxInputs.getProvenanceInput('provenance'), |     provenance: Build.getProvenanceInput('provenance'), | ||||||
|     pull: core.getBooleanInput('pull'), |     pull: core.getBooleanInput('pull'), | ||||||
|     push: core.getBooleanInput('push'), |     push: core.getBooleanInput('push'), | ||||||
|     sbom: core.getInput('sbom'), |     sbom: core.getInput('sbom'), | ||||||
|     secrets: Util.getInputList('secrets', {ignoreComma: true}), |     secrets: Util.getInputList('secrets', {ignoreComma: true}), | ||||||
|     secretEnvs: Util.getInputList('secret-envs'), |     'secret-envs': Util.getInputList('secret-envs'), | ||||||
|     secretFiles: Util.getInputList('secret-files', {ignoreComma: true}), |     'secret-files': Util.getInputList('secret-files', {ignoreComma: true}), | ||||||
|     shmSize: core.getInput('shm-size'), |     'shm-size': core.getInput('shm-size'), | ||||||
|     ssh: Util.getInputList('ssh'), |     ssh: Util.getInputList('ssh'), | ||||||
|     tags: Util.getInputList('tags'), |     tags: Util.getInputList('tags'), | ||||||
|     target: core.getInput('target'), |     target: core.getInput('target'), | ||||||
|     ulimit: Util.getInputList('ulimit', {ignoreComma: true}), |     ulimit: Util.getInputList('ulimit', {ignoreComma: true}), | ||||||
|     githubToken: core.getInput('github-token') |     'github-token': core.getInput('github-token') | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -92,19 +93,12 @@ export async function getArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<s | |||||||
|  |  | ||||||
| async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit): Promise<Array<string>> { | async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit): Promise<Array<string>> { | ||||||
|   const args: Array<string> = ['build']; |   const args: Array<string> = ['build']; | ||||||
|   await Util.asyncForEach(inputs.addHosts, async addHost => { |   await Util.asyncForEach(inputs['add-hosts'], async addHost => { | ||||||
|     args.push('--add-host', addHost); |     args.push('--add-host', addHost); | ||||||
|   }); |   }); | ||||||
|   if (inputs.allow.length > 0) { |   if (inputs.allow.length > 0) { | ||||||
|     args.push('--allow', inputs.allow.join(',')); |     args.push('--allow', inputs.allow.join(',')); | ||||||
|   } |   } | ||||||
|   if (await toolkit.buildx.versionSatisfies('>=0.10.0')) { |  | ||||||
|     await Util.asyncForEach(inputs.attests, async attest => { |  | ||||||
|       args.push('--attest', attest); |  | ||||||
|     }); |  | ||||||
|   } else if (inputs.attests.length > 0) { |  | ||||||
|     core.warning("Attestations are only supported by buildx >= 0.10.0; the input 'attests' is ignored."); |  | ||||||
|   } |  | ||||||
|   if (await toolkit.buildx.versionSatisfies('>=0.12.0')) { |   if (await toolkit.buildx.versionSatisfies('>=0.12.0')) { | ||||||
|     await Util.asyncForEach(inputs.annotations, async annotation => { |     await Util.asyncForEach(inputs.annotations, async annotation => { | ||||||
|       args.push('--annotation', annotation); |       args.push('--annotation', annotation); | ||||||
| @@ -112,28 +106,28 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit): | |||||||
|   } else if (inputs.annotations.length > 0) { |   } else if (inputs.annotations.length > 0) { | ||||||
|     core.warning("Annotations are only supported by buildx >= 0.12.0; the input 'annotations' is ignored."); |     core.warning("Annotations are only supported by buildx >= 0.12.0; the input 'annotations' is ignored."); | ||||||
|   } |   } | ||||||
|   await Util.asyncForEach(inputs.buildArgs, async buildArg => { |   await Util.asyncForEach(inputs['build-args'], async buildArg => { | ||||||
|     args.push('--build-arg', buildArg); |     args.push('--build-arg', buildArg); | ||||||
|   }); |   }); | ||||||
|   if (await toolkit.buildx.versionSatisfies('>=0.8.0')) { |   if (await toolkit.buildx.versionSatisfies('>=0.8.0')) { | ||||||
|     await Util.asyncForEach(inputs.buildContexts, async buildContext => { |     await Util.asyncForEach(inputs['build-contexts'], async buildContext => { | ||||||
|       args.push('--build-context', buildContext); |       args.push('--build-context', buildContext); | ||||||
|     }); |     }); | ||||||
|   } else if (inputs.buildContexts.length > 0) { |   } else if (inputs['build-contexts'].length > 0) { | ||||||
|     core.warning("Build contexts are only supported by buildx >= 0.8.0; the input 'build-contexts' is ignored."); |     core.warning("Build contexts are only supported by buildx >= 0.8.0; the input 'build-contexts' is ignored."); | ||||||
|   } |   } | ||||||
|   await Util.asyncForEach(inputs.cacheFrom, async cacheFrom => { |   await Util.asyncForEach(inputs['cache-from'], async cacheFrom => { | ||||||
|     args.push('--cache-from', cacheFrom); |     args.push('--cache-from', cacheFrom); | ||||||
|   }); |   }); | ||||||
|   await Util.asyncForEach(inputs.cacheTo, async cacheTo => { |   await Util.asyncForEach(inputs['cache-to'], async cacheTo => { | ||||||
|     args.push('--cache-to', cacheTo); |     args.push('--cache-to', cacheTo); | ||||||
|   }); |   }); | ||||||
|   if (inputs.cgroupParent) { |   if (inputs['cgroup-parent']) { | ||||||
|     args.push('--cgroup-parent', inputs.cgroupParent); |     args.push('--cgroup-parent', inputs['cgroup-parent']); | ||||||
|   } |   } | ||||||
|   await Util.asyncForEach(inputs.secretEnvs, async secretEnv => { |   await Util.asyncForEach(inputs['secret-envs'], async secretEnv => { | ||||||
|     try { |     try { | ||||||
|       args.push('--secret', BuildxInputs.resolveBuildSecretEnv(secretEnv)); |       args.push('--secret', Build.resolveSecretEnv(secretEnv)); | ||||||
|     } catch (err) { |     } catch (err) { | ||||||
|       core.warning(err.message); |       core.warning(err.message); | ||||||
|     } |     } | ||||||
| @@ -141,13 +135,13 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit): | |||||||
|   if (inputs.file) { |   if (inputs.file) { | ||||||
|     args.push('--file', inputs.file); |     args.push('--file', inputs.file); | ||||||
|   } |   } | ||||||
|   if (!BuildxInputs.hasLocalExporter(inputs.outputs) && !BuildxInputs.hasTarExporter(inputs.outputs) && (inputs.platforms.length == 0 || (await toolkit.buildx.versionSatisfies('>=0.4.2')))) { |   if (!Build.hasLocalExporter(inputs.outputs) && !Build.hasTarExporter(inputs.outputs) && (inputs.platforms.length == 0 || (await toolkit.buildx.versionSatisfies('>=0.4.2')))) { | ||||||
|     args.push('--iidfile', BuildxInputs.getBuildImageIDFilePath()); |     args.push('--iidfile', toolkit.buildxBuild.getImageIDFilePath()); | ||||||
|   } |   } | ||||||
|   await Util.asyncForEach(inputs.labels, async label => { |   await Util.asyncForEach(inputs.labels, async label => { | ||||||
|     args.push('--label', label); |     args.push('--label', label); | ||||||
|   }); |   }); | ||||||
|   await Util.asyncForEach(inputs.noCacheFilters, async noCacheFilter => { |   await Util.asyncForEach(inputs['no-cache-filters'], async noCacheFilter => { | ||||||
|     args.push('--no-cache-filter', noCacheFilter); |     args.push('--no-cache-filter', noCacheFilter); | ||||||
|   }); |   }); | ||||||
|   await Util.asyncForEach(inputs.outputs, async output => { |   await Util.asyncForEach(inputs.outputs, async output => { | ||||||
| @@ -157,46 +151,29 @@ async function getBuildArgs(inputs: Inputs, context: string, toolkit: Toolkit): | |||||||
|     args.push('--platform', inputs.platforms.join(',')); |     args.push('--platform', inputs.platforms.join(',')); | ||||||
|   } |   } | ||||||
|   if (await toolkit.buildx.versionSatisfies('>=0.10.0')) { |   if (await toolkit.buildx.versionSatisfies('>=0.10.0')) { | ||||||
|     if (inputs.provenance) { |     args.push(...(await getAttestArgs(inputs, toolkit))); | ||||||
|       args.push('--provenance', inputs.provenance); |   } else { | ||||||
|     } else if ((await toolkit.buildkit.versionSatisfies(inputs.builder, '>=0.11.0')) && !BuildxInputs.hasDockerExporter(inputs.outputs, inputs.load)) { |     core.warning("Attestations are only supported by buildx >= 0.10.0; the inputs 'attests', 'provenance' and 'sbom' are ignored."); | ||||||
|       // if provenance not specified and BuildKit version compatible for |  | ||||||
|       // attestation, set default provenance. Also needs to make sure user |  | ||||||
|       // doesn't want to explicitly load the image to docker. |  | ||||||
|       if (GitHub.context.payload.repository?.private ?? false) { |  | ||||||
|         // if this is a private repository, we set the default provenance |  | ||||||
|         // attributes being set in buildx: https://github.com/docker/buildx/blob/fb27e3f919dcbf614d7126b10c2bc2d0b1927eb6/build/build.go#L603 |  | ||||||
|         args.push('--provenance', BuildxInputs.resolveProvenanceAttrs(`mode=min,inline-only=true`)); |  | ||||||
|       } else { |  | ||||||
|         // for a public repository, we set max provenance mode. |  | ||||||
|         args.push('--provenance', BuildxInputs.resolveProvenanceAttrs(`mode=max`)); |  | ||||||
|       } |  | ||||||
|     } |  | ||||||
|     if (inputs.sbom) { |  | ||||||
|       args.push('--sbom', inputs.sbom); |  | ||||||
|     } |  | ||||||
|   } else if (inputs.provenance || inputs.sbom) { |  | ||||||
|     core.warning("Attestations are only supported by buildx >= 0.10.0; the inputs 'provenance' and 'sbom' are ignored."); |  | ||||||
|   } |   } | ||||||
|   await Util.asyncForEach(inputs.secrets, async secret => { |   await Util.asyncForEach(inputs.secrets, async secret => { | ||||||
|     try { |     try { | ||||||
|       args.push('--secret', BuildxInputs.resolveBuildSecretString(secret)); |       args.push('--secret', Build.resolveSecretString(secret)); | ||||||
|     } catch (err) { |     } catch (err) { | ||||||
|       core.warning(err.message); |       core.warning(err.message); | ||||||
|     } |     } | ||||||
|   }); |   }); | ||||||
|   await Util.asyncForEach(inputs.secretFiles, async secretFile => { |   await Util.asyncForEach(inputs['secret-files'], async secretFile => { | ||||||
|     try { |     try { | ||||||
|       args.push('--secret', BuildxInputs.resolveBuildSecretFile(secretFile)); |       args.push('--secret', Build.resolveSecretFile(secretFile)); | ||||||
|     } catch (err) { |     } catch (err) { | ||||||
|       core.warning(err.message); |       core.warning(err.message); | ||||||
|     } |     } | ||||||
|   }); |   }); | ||||||
|   if (inputs.githubToken && !BuildxInputs.hasGitAuthTokenSecret(inputs.secrets) && context.startsWith(Context.gitContext())) { |   if (inputs['github-token'] && !Build.hasGitAuthTokenSecret(inputs.secrets) && context.startsWith(Context.gitContext())) { | ||||||
|     args.push('--secret', BuildxInputs.resolveBuildSecretString(`GIT_AUTH_TOKEN=${inputs.githubToken}`)); |     args.push('--secret', Build.resolveSecretString(`GIT_AUTH_TOKEN=${inputs['github-token']}`)); | ||||||
|   } |   } | ||||||
|   if (inputs.shmSize) { |   if (inputs['shm-size']) { | ||||||
|     args.push('--shm-size', inputs.shmSize); |     args.push('--shm-size', inputs['shm-size']); | ||||||
|   } |   } | ||||||
|   await Util.asyncForEach(inputs.ssh, async ssh => { |   await Util.asyncForEach(inputs.ssh, async ssh => { | ||||||
|     args.push('--ssh', ssh); |     args.push('--ssh', ssh); | ||||||
| @@ -222,12 +199,12 @@ async function getCommonArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<st | |||||||
|     args.push('--load'); |     args.push('--load'); | ||||||
|   } |   } | ||||||
|   if (await toolkit.buildx.versionSatisfies('>=0.6.0')) { |   if (await toolkit.buildx.versionSatisfies('>=0.6.0')) { | ||||||
|     args.push('--metadata-file', BuildxInputs.getBuildMetadataFilePath()); |     args.push('--metadata-file', toolkit.buildxBuild.getMetadataFilePath()); | ||||||
|   } |   } | ||||||
|   if (inputs.network) { |   if (inputs.network) { | ||||||
|     args.push('--network', inputs.network); |     args.push('--network', inputs.network); | ||||||
|   } |   } | ||||||
|   if (inputs.noCache) { |   if (inputs['no-cache']) { | ||||||
|     args.push('--no-cache'); |     args.push('--no-cache'); | ||||||
|   } |   } | ||||||
|   if (inputs.pull) { |   if (inputs.pull) { | ||||||
| @@ -238,3 +215,52 @@ async function getCommonArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<st | |||||||
|   } |   } | ||||||
|   return args; |   return args; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | async function getAttestArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> { | ||||||
|  |   const args: Array<string> = []; | ||||||
|  |  | ||||||
|  |   // check if provenance attestation is set in attests input | ||||||
|  |   let hasAttestProvenance = false; | ||||||
|  |   await Util.asyncForEach(inputs.attests, async (attest: string) => { | ||||||
|  |     if (Build.hasAttestationType('provenance', attest)) { | ||||||
|  |       hasAttestProvenance = true; | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   let provenanceSet = false; | ||||||
|  |   let sbomSet = false; | ||||||
|  |   if (inputs.provenance) { | ||||||
|  |     args.push('--attest', Build.resolveAttestationAttrs(`type=provenance,${inputs.provenance}`)); | ||||||
|  |     provenanceSet = true; | ||||||
|  |   } else if (!hasAttestProvenance && (await toolkit.buildkit.versionSatisfies(inputs.builder, '>=0.11.0')) && !Build.hasDockerExporter(inputs.outputs, inputs.load)) { | ||||||
|  |     // if provenance not specified in provenance or attests inputs and BuildKit | ||||||
|  |     // version compatible for attestation, set default provenance. Also needs | ||||||
|  |     // to make sure user doesn't want to explicitly load the image to docker. | ||||||
|  |     if (GitHub.context.payload.repository?.private ?? false) { | ||||||
|  |       // if this is a private repository, we set the default provenance | ||||||
|  |       // attributes being set in buildx: https://github.com/docker/buildx/blob/fb27e3f919dcbf614d7126b10c2bc2d0b1927eb6/build/build.go#L603 | ||||||
|  |       args.push('--attest', `type=provenance,${Build.resolveProvenanceAttrs(`mode=min,inline-only=true`)}`); | ||||||
|  |     } else { | ||||||
|  |       // for a public repository, we set max provenance mode. | ||||||
|  |       args.push('--attest', `type=provenance,${Build.resolveProvenanceAttrs(`mode=max`)}`); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   if (inputs.sbom) { | ||||||
|  |     args.push('--attest', Build.resolveAttestationAttrs(`type=sbom,${inputs.sbom}`)); | ||||||
|  |     sbomSet = true; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   // set attests but check if provenance or sbom types already set as | ||||||
|  |   // provenance and sbom inputs take precedence over attests input. | ||||||
|  |   await Util.asyncForEach(inputs.attests, async (attest: string) => { | ||||||
|  |     if (!Build.hasAttestationType('provenance', attest) && !Build.hasAttestationType('sbom', attest)) { | ||||||
|  |       args.push('--attest', Build.resolveAttestationAttrs(attest)); | ||||||
|  |     } else if (!provenanceSet && Build.hasAttestationType('provenance', attest)) { | ||||||
|  |       args.push('--attest', Build.resolveProvenanceAttrs(attest)); | ||||||
|  |     } else if (!sbomSet && Build.hasAttestationType('sbom', attest)) { | ||||||
|  |       args.push('--attest', attest); | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   return args; | ||||||
|  | } | ||||||
|   | |||||||
							
								
								
									
										21
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								src/main.ts
									
									
									
									
									
								
							| @@ -3,13 +3,14 @@ import * as path from 'path'; | |||||||
| import * as stateHelper from './state-helper'; | import * as stateHelper from './state-helper'; | ||||||
| import * as core from '@actions/core'; | import * as core from '@actions/core'; | ||||||
| import * as actionsToolkit from '@docker/actions-toolkit'; | import * as actionsToolkit from '@docker/actions-toolkit'; | ||||||
|  |  | ||||||
| import {Context} from '@docker/actions-toolkit/lib/context'; | import {Context} from '@docker/actions-toolkit/lib/context'; | ||||||
| import {Docker} from '@docker/actions-toolkit/lib/docker/docker'; | import {Docker} from '@docker/actions-toolkit/lib/docker/docker'; | ||||||
| import {Exec} from '@docker/actions-toolkit/lib/exec'; | import {Exec} from '@docker/actions-toolkit/lib/exec'; | ||||||
| import {GitHub} from '@docker/actions-toolkit/lib/github'; | import {GitHub} from '@docker/actions-toolkit/lib/github'; | ||||||
| import {Inputs as BuildxInputs} from '@docker/actions-toolkit/lib/buildx/inputs'; |  | ||||||
| import {Toolkit} from '@docker/actions-toolkit/lib/toolkit'; | import {Toolkit} from '@docker/actions-toolkit/lib/toolkit'; | ||||||
| import {ConfigFile} from '@docker/actions-toolkit/lib/types/docker'; |  | ||||||
|  | import {ConfigFile} from '@docker/actions-toolkit/lib/types/docker/docker'; | ||||||
|  |  | ||||||
| import * as context from './context'; | import * as context from './context'; | ||||||
|  |  | ||||||
| @@ -74,6 +75,11 @@ actionsToolkit.run( | |||||||
|       await toolkit.buildx.printVersion(); |       await toolkit.buildx.printVersion(); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  |     await core.group(`Builder info`, async () => { | ||||||
|  |       const builder = await toolkit.builder.inspect(inputs.builder); | ||||||
|  |       core.info(JSON.stringify(builder, null, 2)); | ||||||
|  |     }); | ||||||
|  |  | ||||||
|     const args: string[] = await context.getArgs(inputs, toolkit); |     const args: string[] = await context.getArgs(inputs, toolkit); | ||||||
|     core.debug(`context.getArgs: ${JSON.stringify(args)}`); |     core.debug(`context.getArgs: ${JSON.stringify(args)}`); | ||||||
|  |  | ||||||
| @@ -89,9 +95,9 @@ actionsToolkit.run( | |||||||
|       } |       } | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     const imageID = BuildxInputs.resolveBuildImageID(); |     const imageID = toolkit.buildxBuild.resolveImageID(); | ||||||
|     const metadata = BuildxInputs.resolveBuildMetadata(); |     const metadata = toolkit.buildxBuild.resolveMetadata(); | ||||||
|     const digest = BuildxInputs.resolveDigest(); |     const digest = toolkit.buildxBuild.resolveDigest(); | ||||||
|  |  | ||||||
|     if (imageID) { |     if (imageID) { | ||||||
|       await core.group(`ImageID`, async () => { |       await core.group(`ImageID`, async () => { | ||||||
| @@ -107,8 +113,9 @@ actionsToolkit.run( | |||||||
|     } |     } | ||||||
|     if (metadata) { |     if (metadata) { | ||||||
|       await core.group(`Metadata`, async () => { |       await core.group(`Metadata`, async () => { | ||||||
|         core.info(metadata); |         const metadatadt = JSON.stringify(metadata, null, 2); | ||||||
|         core.setOutput('metadata', metadata); |         core.info(metadatadt); | ||||||
|  |         core.setOutput('metadata', metadatadt); | ||||||
|       }); |       }); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user