mirror of
				https://github.com/docker/setup-buildx-action.git
				synced 2025-10-31 11:04:19 +08:00 
			
		
		
		
	check if driver compatible with keep-state
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									4143b5899b
								
							
						
					
					
						commit
						36590ad0c1
					
				| @ -86,8 +86,9 @@ The following inputs can be used as `step.with` keys: | ||||
| > ``` | ||||
| 
 | ||||
| | Name                         | Type     | Default            | Description                                                                                                                                                                 | | ||||
| |------------------------------|----------|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||||
| |------------------------------|----------|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||||
| | `version`                    | String   |                    | [Buildx](https://github.com/docker/buildx) version. (eg. `v0.3.0`, `latest`, `https://github.com/docker/buildx.git#master`)                                                 | | ||||
| | `name`                       | String   |                    | Name of the builder. If not specified, one will be generated or if it already exists, it will be used instead of creating a new one                                         | | ||||
| | `driver`                     | String   | `docker-container` | Sets the [builder driver](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver) to be used                                                            | | ||||
| | `driver-opts`                | List     |                    | List of additional [driver-specific options](https://docs.docker.com/engine/reference/commandline/buildx_create/#driver-opt) (eg. `image=moby/buildkit:master`)             | | ||||
| | `buildkitd-flags`            | String   |                    | [BuildKit daemon flags](https://docs.docker.com/engine/reference/commandline/buildx_create/#buildkitd-flags)                                                                | | ||||
| @ -96,11 +97,11 @@ The following inputs can be used as `step.with` keys: | ||||
| | `install`                    | Bool     | `false`            | Sets up `docker build` command as an alias to `docker buildx`                                                                                                               | | ||||
| | `use`                        | Bool     | `true`             | Switch to this builder instance                                                                                                                                             | | ||||
| | `endpoint`                   | String   |                    | [Optional address for docker socket](https://docs.docker.com/engine/reference/commandline/buildx_create/#description) or context from `docker context ls`                   | | ||||
| | `platforms`                  | List/CSV |                    | Fixed [platforms](https://docs.docker.com/engine/reference/commandline/buildx_create/#platform) for current node. If not empty, values take priority over the detected ones. | | ||||
| | `platforms`                  | List/CSV |                    | Fixed [platforms](https://docs.docker.com/engine/reference/commandline/buildx_create/#platform) for current node. If not empty, values take priority over the detected ones | | ||||
| | `append`                     | YAML     |                    | [Append additional nodes](https://docs.docker.com/build/ci/github-actions/configure-builder/#append-additional-nodes-to-the-builder) to the builder                         | | ||||
| | `keep-state`                 | Bool     | `false`            | Keep BuildKit state on `cleanup`. This is only useful on persistent self-hosted runners                                                                                     | | ||||
| | `cache-binary`               | Bool     | `true`             | Cache buildx binary to GitHub Actions cache backend                                                                                                                         | | ||||
| | `cleanup`                    | Bool     | `true`             | Cleanup temp files and remove builder at the end of a job                                                                                                                   | | ||||
| | `name`                       | String   | Default Docker Context | Name of the builder to create or use. If a builder with this name already exists, it will be used instead of creating a new one.                                              | | ||||
| 
 | ||||
| > [!IMPORTANT] | ||||
| > If you set the `buildkitd-flags` input, the default flags (`--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host`) | ||||
|  | ||||
							
								
								
									
										13
									
								
								action.yml
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								action.yml
									
									
									
									
									
								
							| @ -34,6 +34,9 @@ inputs: | ||||
|     description: 'Switch to this builder instance' | ||||
|     default: 'true' | ||||
|     required: false | ||||
|   name: | ||||
|     description: 'Name of the builder. If not specified, one will be generated or if it already exists, it will be used instead of creating a new one.' | ||||
|     required: false | ||||
|   endpoint: | ||||
|     description: 'Optional address for docker socket or context from `docker context ls`' | ||||
|     required: false | ||||
| @ -43,6 +46,10 @@ inputs: | ||||
|   append: | ||||
|     description: 'Append additional nodes to the builder' | ||||
|     required: false | ||||
|   keep-state: | ||||
|     description: 'Keep BuildKit state on cleanup. This is only useful on persistent self-hosted runners.' | ||||
|     default: 'false' | ||||
|     required: false | ||||
|   cache-binary: | ||||
|     description: 'Cache buildx binary to GitHub Actions cache backend' | ||||
|     default: 'true' | ||||
| @ -50,12 +57,6 @@ inputs: | ||||
|   cleanup: | ||||
|     description: 'Cleanup temp files and remove builder at the end of a job' | ||||
|     default: 'true' | ||||
|   keep-state: | ||||
|     description: 'Keep BuildKit state on cleanup. This is only useful on persistent self-hosted runners.' | ||||
|     default: 'false' | ||||
|     required: false | ||||
|   name: | ||||
|     description: 'Builder name set when creating the builder. If not specified, one will be generated.' | ||||
|     required: false | ||||
|   # TODO: remove deprecated config and config-inline inputs | ||||
|   config: | ||||
|  | ||||
| @ -42,17 +42,14 @@ export async function getInputs(): Promise<Inputs> { | ||||
|     buildkitdConfig: core.getInput('buildkitd-config') || core.getInput('config'), | ||||
|     buildkitdConfigInline: core.getInput('buildkitd-config-inline') || core.getInput('config-inline'), | ||||
|     append: core.getInput('append'), | ||||
|     keepState: core.getBooleanInput('keep-state'), | ||||
|     cacheBinary: core.getBooleanInput('cache-binary'), | ||||
|     cleanup: core.getBooleanInput('cleanup'), | ||||
|     keepState: core.getBooleanInput('keep-state') | ||||
|     cleanup: core.getBooleanInput('cleanup') | ||||
|   }; | ||||
| } | ||||
| 
 | ||||
| export async function getBuilderName(name: string, driver: string): Promise<string> { | ||||
|   if (driver == 'docker') { | ||||
|     return await Docker.context(); | ||||
|   } | ||||
|   return name || `builder-${crypto.randomUUID()}`; | ||||
|   return driver == 'docker' ? await Docker.context() : name || `builder-${crypto.randomUUID()}`; | ||||
| } | ||||
| 
 | ||||
| export async function getCreateArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> { | ||||
|  | ||||
| @ -28,6 +28,12 @@ actionsToolkit.run( | ||||
|     const standalone = await toolkit.buildx.isStandalone(); | ||||
|     stateHelper.setStandalone(standalone); | ||||
| 
 | ||||
|     if (inputs.keepState && inputs.driver !== 'docker-container') { | ||||
|       // https://docs.docker.com/reference/cli/docker/buildx/rm/#keep-state
 | ||||
|       throw new Error(`Cannot use keep-state with ${inputs.driver} driver`); | ||||
|     } | ||||
|     stateHelper.setKeepState(inputs.keepState); | ||||
| 
 | ||||
|     await core.group(`Docker info`, async () => { | ||||
|       try { | ||||
|         await Docker.printVersion(); | ||||
| @ -115,7 +121,6 @@ actionsToolkit.run( | ||||
|         }); | ||||
|       } | ||||
|     } | ||||
|     stateHelper.setKeepState(inputs.keepState); | ||||
| 
 | ||||
|     if (inputs.driver !== 'docker') { | ||||
|       await core.group(`Creating a new builder instance`, async () => { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 CrazyMax
						CrazyMax