mirror of
				https://git.mirrors.martin98.com/https://github.com/docker/setup-docker-action
				synced 2025-10-31 16:11:06 +08:00 
			
		
		
		
	Merge pull request #58 from crazy-max/set-host
set-host input to set DOCKER_HOST env var
This commit is contained in:
		
						commit
						f1d16883d0
					
				
							
								
								
									
										20
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							| @ -249,3 +249,23 @@ jobs: | ||||
|         name: Dump context | ||||
|         if: always() | ||||
|         uses: crazy-max/ghaction-dump-context@v2 | ||||
| 
 | ||||
|   set-host: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v4 | ||||
|       - | ||||
|         name: Set up Docker | ||||
|         uses: ./ | ||||
|         with: | ||||
|           set-host: true | ||||
|       - | ||||
|         name: List contexts | ||||
|         run: | | ||||
|           docker context ls | ||||
|       - | ||||
|         name: Dump context | ||||
|         if: always() | ||||
|         uses: crazy-max/ghaction-dump-context@v2 | ||||
|  | ||||
| @ -106,6 +106,7 @@ The following inputs can be used as `step.with` keys | ||||
| | `channel`       | String | `stable`              | Docker CE [channel](https://download.docker.com/linux/static/) (e.g, `stable`, `edge` or `test`).                           | | ||||
| | `daemon-config` | String |                       | [Docker daemon JSON configuration](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file) | | ||||
| | `context`       | String | `setup-docker-action` | Docker context name.                                                                                                        | | ||||
| | `set-host`      | Bool   | `false`               | Set `DOCKER_HOST` environment variable to docker socket path.                                                               | | ||||
| 
 | ||||
| ### outputs | ||||
| 
 | ||||
|  | ||||
| @ -18,12 +18,14 @@ describe('getInputs', () => { | ||||
|       0, | ||||
|       new Map<string, string>([ | ||||
|         ['version', 'v24.0.8'], | ||||
|         ['set-host', 'false'], | ||||
|       ]), | ||||
|       { | ||||
|         version: 'v24.0.8', | ||||
|         channel: '', | ||||
|         context: '', | ||||
|         daemonConfig: '', | ||||
|         setHost: false | ||||
|       } as context.Inputs | ||||
|     ], | ||||
|     [ | ||||
| @ -33,22 +35,27 @@ describe('getInputs', () => { | ||||
|         ['channel', 'test'], | ||||
|         ['context', 'foo'], | ||||
|         ['daemon-config', `{"debug":true,"features":{"containerd-snapshotter":true}}`], | ||||
|         ['set-host', 'false'], | ||||
|       ]), | ||||
|       { | ||||
|         version: 'v24.0.0-rc.4', | ||||
|         channel: 'test', | ||||
|         context: 'foo', | ||||
|         daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`, | ||||
|         setHost: false | ||||
|       } as context.Inputs | ||||
|     ], | ||||
|     [ | ||||
|       2, | ||||
|       new Map<string, string>([]), | ||||
|       new Map<string, string>([ | ||||
|         ['set-host', 'true'], | ||||
|       ]), | ||||
|       { | ||||
|         version: 'latest', | ||||
|         channel: '', | ||||
|         context: '', | ||||
|         daemonConfig: '', | ||||
|         setHost: true | ||||
|       } as context.Inputs | ||||
|     ] | ||||
|   ])( | ||||
|  | ||||
| @ -20,6 +20,10 @@ inputs: | ||||
|   context: | ||||
|     description: 'Docker context name. (default setup-docker-action)' | ||||
|     required: false | ||||
|   set-host: | ||||
|     description: 'Set DOCKER_HOST environment variable to docker socket path' | ||||
|     default: 'false' | ||||
|     required: false | ||||
| 
 | ||||
| outputs: | ||||
|   sock: | ||||
|  | ||||
							
								
								
									
										6
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								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
											
										
									
								
							| @ -5,6 +5,7 @@ export interface Inputs { | ||||
|   channel: string; | ||||
|   daemonConfig?: string; | ||||
|   context: string; | ||||
|   setHost: boolean; | ||||
| } | ||||
| 
 | ||||
| export function getInputs(): Inputs { | ||||
| @ -12,6 +13,7 @@ export function getInputs(): Inputs { | ||||
|     version: core.getInput('version') || 'latest', | ||||
|     channel: core.getInput('channel'), | ||||
|     daemonConfig: core.getInput('daemon-config'), | ||||
|     context: core.getInput('context') | ||||
|     context: core.getInput('context'), | ||||
|     setHost: core.getBooleanInput('set-host') | ||||
|   }; | ||||
| } | ||||
|  | ||||
| @ -39,6 +39,13 @@ actionsToolkit.run( | ||||
|         core.info(`sock=${sockPath}`); | ||||
|         core.setOutput('sock', sockPath); | ||||
|       }); | ||||
| 
 | ||||
|       if (input.setHost) { | ||||
|         await core.group(`Setting Docker host`, async () => { | ||||
|           core.exportVariable('DOCKER_HOST', sockPath); | ||||
|           core.info(`DOCKER_HOST=${sockPath}`); | ||||
|         }); | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
|     await core.group(`Docker info`, async () => { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 CrazyMax
						CrazyMax