Add secrets input
Use Git as default context Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									bd6a01893d
								
							
						
					
					
						commit
						f295fbf080
					
				
							
								
								
									
										114
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										114
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							| @ -11,7 +11,62 @@ on: | ||||
|       - v2-working-branch # remove when merged to master | ||||
| 
 | ||||
| jobs: | ||||
|   single: | ||||
|   git-context: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         buildx-version: | ||||
|           - latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Run local registry | ||||
|         run: | | ||||
|           docker run -d -p 5000:5000 registry:2 | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2.3.1 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@master | ||||
|         with: | ||||
|           platforms: all | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         id: buildx | ||||
|         uses: docker/setup-buildx-action@master | ||||
|         with: | ||||
|           version: ${{ matrix.buildx-version }} | ||||
|           driver-opt: network=host | ||||
|           buildkitd-flags: --allow-insecure-entitlement security.insecure | ||||
|       - | ||||
|         name: Build and push | ||||
|         id: docker_build | ||||
|         uses: ./ | ||||
|         with: | ||||
|           file: ./test/Dockerfile | ||||
|           builder: ${{ steps.buildx.outputs.name }} | ||||
|           platforms: linux/amd64,linux/arm64 | ||||
|           allow: network.host,security.insecure | ||||
|           push: true | ||||
|           tags: | | ||||
|             localhost:5000/name/app:latest | ||||
|             localhost:5000/name/app:1.0.0 | ||||
|           secrets: | | ||||
|             GIT_AUTH_TOKEN=${{ github.token }} | ||||
|       - | ||||
|         name: Inspect | ||||
|         run: | | ||||
|           docker buildx imagetools inspect localhost:5000/name/app:1.0.0 | ||||
|       - | ||||
|         name: Image digest | ||||
|         run: echo ${{ steps.docker_build.outputs.digest }} | ||||
|       - | ||||
|         name: Dump context | ||||
|         if: always() | ||||
|         uses: crazy-max/ghaction-dump-context@v1 | ||||
| 
 | ||||
|   path-context: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
| @ -184,60 +239,3 @@ jobs: | ||||
|         name: Dump context | ||||
|         if: always() | ||||
|         uses: crazy-max/ghaction-dump-context@v1 | ||||
| 
 | ||||
|   git-context: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         buildx-version: | ||||
|           #- "" # GIT_AUTH_TOKEN not available in the current version on the GitHub Runner | ||||
|           - latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Run local registry | ||||
|         run: | | ||||
|           docker run -d -p 5000:5000 registry:2 | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2.3.1 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@master | ||||
|         with: | ||||
|           platforms: all | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         id: buildx | ||||
|         uses: docker/setup-buildx-action@master | ||||
|         with: | ||||
|           version: ${{ matrix.buildx-version }} | ||||
|           driver-opt: network=host | ||||
|           buildkitd-flags: --allow-insecure-entitlement security.insecure | ||||
|       - | ||||
|         name: Build and push | ||||
|         id: docker_build | ||||
|         uses: ./ | ||||
|         env: | ||||
|           GIT_AUTH_TOKEN: ${{ github.token }} | ||||
|         with: | ||||
|           context: "${{ github.repositoryUrl }}#${{ github.ref }}" | ||||
|           file: ./test/Dockerfile | ||||
|           builder: ${{ steps.buildx.outputs.name }} | ||||
|           platforms: linux/amd64,linux/arm64 | ||||
|           allow: network.host,security.insecure | ||||
|           push: true | ||||
|           tags: | | ||||
|             localhost:5000/name/app:latest | ||||
|             localhost:5000/name/app:1.0.0 | ||||
|       - | ||||
|         name: Inspect | ||||
|         run: | | ||||
|           docker buildx imagetools inspect localhost:5000/name/app:1.0.0 | ||||
|       - | ||||
|         name: Image digest | ||||
|         run: echo ${{ steps.docker_build.outputs.digest }} | ||||
|       - | ||||
|         name: Dump context | ||||
|         if: always() | ||||
|         uses: crazy-max/ghaction-dump-context@v1 | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| # Changelog | ||||
| 
 | ||||
| ## 2.0.0 (2020/08/??) | ||||
| ## 2.0.0 (2020/??/??) | ||||
| 
 | ||||
| v2 of Build Push action uses Docker [Buildx](https://github.com/docker/buildx). It's also rewritten as | ||||
| a [typescript-action](https://github.com/actions/typescript-action/) to be as closed as possible of | ||||
| @ -16,6 +16,7 @@ the [GitHub Runner](https://github.com/actions/virtual-environments) during its | ||||
| * Add [`outputs`](https://github.com/docker/buildx#-o---outputpath-typetypekeyvalue) input | ||||
| * Add [`cache-from`](https://github.com/docker/buildx#--cache-fromnametypetypekeyvalue) input | ||||
| * Add [`cache-to`](https://github.com/docker/buildx#--cache-tonametypetypekeyvalue) input | ||||
| * Add `secrets` input | ||||
| * Review `tags` input | ||||
| * Remove `repository`, `username`, `password`, `registry`, `cache_froms` inputs | ||||
| * Remove `tag_with_sha`, `tag_with_ref`, `add_git_labels` inputs | ||||
|  | ||||
							
								
								
									
										149
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										149
									
								
								README.md
									
									
									
									
									
								
							| @ -1,11 +1,11 @@ | ||||
| [](https://github.com/docker/build-push-action/releases/latest) | ||||
| [](https://github.com/marketplace/actions/docker-build-push-images) | ||||
| [](https://github.com/marketplace/actions/docker-build-push) | ||||
| [](https://github.com/docker/build-push-action/actions?workflow=ci) | ||||
| [](https://github.com/docker/build-push-action/actions?workflow=test) | ||||
| 
 | ||||
| ## About | ||||
| 
 | ||||
| GitHub Action to build and push Docker images. | ||||
| GitHub Action to build and push Docker images with [Buildx](https://github.com/docker/buildx). | ||||
| 
 | ||||
| > :bulb: See also: | ||||
| > * [login](https://github.com/docker/login-action) action | ||||
| @ -17,16 +17,15 @@ GitHub Action to build and push Docker images. | ||||
| ___ | ||||
| 
 | ||||
| * [Usage](#usage) | ||||
|   * [Quick start](#quick-start) | ||||
|   * [Git context](#git-context) | ||||
|   * [Path context](#path-context) | ||||
|   * [Isolated builders](#isolated-builders) | ||||
|   * [Multi-platform image](#multi-platform-image) | ||||
|   * [Git context](#git-context) | ||||
|   * [Leverage GitHub cache](#leverage-github-cache) | ||||
|   * [Complete workflow](#complete-workflow) | ||||
| * [Customizing](#customizing) | ||||
|   * [inputs](#inputs) | ||||
|   * [outputs](#outputs) | ||||
|   * [environment variables](#environment-variables) | ||||
| * [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot) | ||||
| * [Limitation](#limitation) | ||||
| 
 | ||||
| @ -37,7 +36,9 @@ This action uses our [setup-buildx](https://github.com/docker/setup-buildx-actio | ||||
| provided by [Moby BuildKit](https://github.com/moby/buildkit) builder toolkit. This includes multi-arch build, | ||||
| build-secrets, remote cache, etc. and different builder deployment/namespacing options. | ||||
| 
 | ||||
| ### Quick start | ||||
| ### Git context | ||||
| 
 | ||||
| The default behavior of this action is to use the Git context invoked by your workflow (`https://github.com/owner/repo#ref`). | ||||
| 
 | ||||
| ```yaml | ||||
| name: ci | ||||
| @ -50,9 +51,6 @@ jobs: | ||||
|   main: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@master | ||||
| @ -81,6 +79,69 @@ jobs: | ||||
|         run: echo ${{ steps.docker_build.outputs.digest }} | ||||
| ``` | ||||
| 
 | ||||
| If you use this action in a private repository, you have to pass the `GIT_AUTH_TOKEN` to be able to authenticate | ||||
| against it with buildx: | ||||
| 
 | ||||
| ```yaml | ||||
|       - | ||||
|         name: Build and push | ||||
|         id: docker_build | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           builder: ${{ steps.buildx.outputs.name }} | ||||
|           push: true | ||||
|           tags: user/app:latest | ||||
|           secrets: | | ||||
|             GIT_AUTH_TOKEN=${{ github.token }} | ||||
| ``` | ||||
| 
 | ||||
| ### Path context | ||||
| 
 | ||||
| You can also use the `PATH` context alongside the [`actions/checkout`](https://github.com/actions/checkout/) action. | ||||
| 
 | ||||
| ```yaml | ||||
| name: ci | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: master | ||||
| 
 | ||||
| jobs: | ||||
|   path-context: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@master | ||||
|         with: | ||||
|           platforms: all | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         id: buildx | ||||
|         uses: docker/setup-buildx-action@master | ||||
|         with: | ||||
|           version: latest | ||||
|       - | ||||
|         name: Login to DockerHub | ||||
|         uses: docker/login-action@v1 | ||||
|         with: | ||||
|           username: ${{ secrets.DOCKER_USERNAME }} | ||||
|           password: ${{ secrets.DOCKER_PASSWORD }} | ||||
|       - | ||||
|         name: Build and push | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           builder: ${{ steps.buildx.outputs.name }} | ||||
|           context: . | ||||
|           file: ./Dockerfile | ||||
|           platforms: linux/amd64,linux/arm64,linux/386 | ||||
|           push: true | ||||
|           tags: user/app:latest | ||||
| ``` | ||||
| 
 | ||||
| ### Isolated builders | ||||
| 
 | ||||
| ```yaml | ||||
| @ -94,9 +155,6 @@ jobs: | ||||
|   multi-builders: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         uses: docker/setup-buildx-action@master | ||||
|         id: builder1 | ||||
| @ -168,54 +226,6 @@ jobs: | ||||
|             user/app:1.0.0 | ||||
| ``` | ||||
| 
 | ||||
| ### Git context | ||||
| 
 | ||||
| You can build from Git directly without [`actions/checkout`](https://github.com/actions/checkout/) action, | ||||
| even in private repositories if your `context` is a valid Git url: | ||||
| 
 | ||||
| ```yaml | ||||
| name: ci | ||||
| 
 | ||||
| on: | ||||
|   push: | ||||
|     branches: master | ||||
| 
 | ||||
| jobs: | ||||
|   git-context: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@master | ||||
|         with: | ||||
|           platforms: all | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         id: buildx | ||||
|         uses: docker/setup-buildx-action@master | ||||
|         with: | ||||
|           version: latest | ||||
|       - | ||||
|         name: Login to DockerHub | ||||
|         uses: docker/login-action@v1 | ||||
|         with: | ||||
|           username: ${{ secrets.DOCKER_USERNAME }} | ||||
|           password: ${{ secrets.DOCKER_PASSWORD }} | ||||
|       - | ||||
|         name: Build and push | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           builder: ${{ steps.buildx.outputs.name }} | ||||
|           context: "${{ github.repositoryUrl }}#${{ github.ref }}" | ||||
|           platforms: linux/amd64,linux/arm64,linux/386 | ||||
|           push: true | ||||
|           tags: | | ||||
|             name/app:latest | ||||
|             name/app:1.0.0 | ||||
|         env: | ||||
|           GIT_AUTH_TOKEN: ${{ github.token }} | ||||
| ``` | ||||
| 
 | ||||
| ### Leverage GitHub cache | ||||
| 
 | ||||
| You can leverage [GitHub cache](https://docs.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows) | ||||
| @ -232,9 +242,6 @@ jobs: | ||||
|   github-cache: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@master | ||||
| @ -355,8 +362,8 @@ Following inputs can be used as `step.with` keys | ||||
| | Name                | Type    | Description                        | | ||||
| |---------------------|---------|------------------------------------| | ||||
| | `builder`           | String  | Builder instance (see [setup-buildx](https://github.com/docker/setup-buildx-action) action) | | ||||
| | `context`           | String  | Build's context is the set of files located in the specified [`PATH` or `URL`](https://docs.docker.com/engine/reference/commandline/build/) (default `.`) | | ||||
| | `file`              | String  | Path to the Dockerfile (default `./Dockerfile`) | | ||||
| | `context`           | String  | Build's context is the set of files located in the specified [`PATH` or `URL`](https://docs.docker.com/engine/reference/commandline/build/) (default [Git context](#git-context)) | | ||||
| | `file`              | String  | Path to the Dockerfile (default `Dockerfile`) | | ||||
| | `build-args`        | List    | List of build-time variables | | ||||
| | `labels`            | List    | List of metadata for an image | | ||||
| | `tags`              | List    | List of tags | | ||||
| @ -370,6 +377,7 @@ Following inputs can be used as `step.with` keys | ||||
| | `outputs`           | CSV     | List of [output destinations](https://github.com/docker/buildx#-o---outputpath-typetypekeyvalue) (format: `type=local,dest=path`) | | ||||
| | `cache-from`        | CSV     | List of [external cache sources](https://github.com/docker/buildx#--cache-fromnametypetypekeyvalue) (eg. `user/app:cache`, `type=local,src=path/to/dir`) | | ||||
| | `cache-to`          | CSV     | List of [cache export destinations](https://github.com/docker/buildx#--cache-tonametypetypekeyvalue) (eg. `user/app:cache`, `type=local,dest=path/to/dir`) | | ||||
| | `secrets`           | CSV     | List of secrets to expose to the build (eg. `key=value`, `GIT_AUTH_TOKEN=mytoken`) | | ||||
| 
 | ||||
| > `List` type can be a comma or newline-delimited string | ||||
| > ```yaml | ||||
| @ -399,17 +407,6 @@ Following outputs are available | ||||
| |---------------|---------|---------------------------------------| | ||||
| | `digest`      | String  | Image content-addressable identifier also called a digest | | ||||
| 
 | ||||
| ### environment variables | ||||
| 
 | ||||
| Following environment variables can be used as `step.env` keys | ||||
| 
 | ||||
| | Name                     | Description                           | | ||||
| |--------------------------|---------------------------------------| | ||||
| | `GIT_AUTH_HEADER`**¹**   | Raw authorization header to authenticate against git repository | | ||||
| | `GIT_AUTH_TOKEN`**¹**    | `x-access-token` basic auth to authenticate against git repository | | ||||
| 
 | ||||
| > **¹** Only used if `input.context` is a valid git uri. | ||||
| 
 | ||||
| ## Keep up-to-date with GitHub Dependabot | ||||
| 
 | ||||
| Since [Dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot) | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| # https://help.github.com/en/articles/metadata-syntax-for-github-actions | ||||
| name: Docker Build Push images | ||||
| name: Docker Build Push | ||||
| description: Build and push Docker images with Buildx | ||||
| author: docker | ||||
| branding: | ||||
| @ -61,6 +61,9 @@ inputs: | ||||
|   cache-to: | ||||
|     description: "List of cache export destinations for buildx (eg. user/app:cache, type=local,dest=path/to/dir)" | ||||
|     required: false | ||||
|   secrets: | ||||
|     description: "List of secrets to expose to the build (eg. key=value, GIT_AUTH_TOKEN=mytoken)" | ||||
|     required: false | ||||
| 
 | ||||
| outputs: | ||||
|   digest: | ||||
| @ -69,3 +72,4 @@ outputs: | ||||
| runs: | ||||
|   using: 'node12' | ||||
|   main: 'dist/index.js' | ||||
|   post: 'dist/index.js' | ||||
|  | ||||
							
								
								
									
										13389
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										13389
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @ -30,11 +30,14 @@ | ||||
|   "dependencies": { | ||||
|     "@actions/core": "^1.2.4", | ||||
|     "@actions/exec": "^1.0.4", | ||||
|     "semver": "^7.3.2" | ||||
|     "@actions/github": "^4.0.0", | ||||
|     "semver": "^7.3.2", | ||||
|     "tmp": "^0.2.1" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@types/jest": "^26.0.3", | ||||
|     "@types/node": "^14.0.14", | ||||
|     "@types/tmp": "^0.2.0", | ||||
|     "@vercel/ncc": "^0.23.0", | ||||
|     "dotenv": "^8.2.0", | ||||
|     "jest": "^26.1.0", | ||||
|  | ||||
| @ -1,5 +1,6 @@ | ||||
| import fs from 'fs'; | ||||
| import path from 'path'; | ||||
| import tmp from 'tmp'; | ||||
| import * as semver from 'semver'; | ||||
| import * as context from './context'; | ||||
| import * as exec from './exec'; | ||||
| @ -16,6 +17,15 @@ export async function getImageID(): Promise<string | undefined> { | ||||
|   return fs.readFileSync(iidFile, {encoding: 'utf-8'}); | ||||
| } | ||||
| 
 | ||||
| export async function getSecret(kvp: string): Promise<string> { | ||||
|   const [key, value] = kvp.split('='); | ||||
|   const secretFile = tmp.tmpNameSync({ | ||||
|     tmpdir: context.tmpDir | ||||
|   }); | ||||
|   await fs.writeFileSync(secretFile, value); | ||||
|   return `id=${key},src=${secretFile}`; | ||||
| } | ||||
| 
 | ||||
| export async function isAvailable(): Promise<Boolean> { | ||||
|   return await exec.exec(`docker`, ['buildx'], true).then(res => { | ||||
|     if (res.stderr != '' && !res.success) { | ||||
|  | ||||
| @ -4,6 +4,7 @@ import * as path from 'path'; | ||||
| import * as semver from 'semver'; | ||||
| import * as buildx from './buildx'; | ||||
| import * as core from '@actions/core'; | ||||
| import * as github from '@actions/github'; | ||||
| 
 | ||||
| export const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'docker-build-push-')); | ||||
| 
 | ||||
| @ -24,12 +25,15 @@ export interface Inputs { | ||||
|   outputs: string[]; | ||||
|   cacheFrom: string[]; | ||||
|   cacheTo: string[]; | ||||
|   secrets: string[]; | ||||
| } | ||||
| 
 | ||||
| export async function getInputs(): Promise<Inputs> { | ||||
|   return { | ||||
|     context: core.getInput('context') || '.', | ||||
|     file: core.getInput('file') || './Dockerfile', | ||||
|     context: | ||||
|       core.getInput('context') || | ||||
|       `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}#${github.context.ref}`, | ||||
|     file: core.getInput('file') || 'Dockerfile', | ||||
|     buildArgs: await getInputList('build-args'), | ||||
|     labels: await getInputList('labels'), | ||||
|     tags: await getInputList('tags'), | ||||
| @ -43,7 +47,8 @@ export async function getInputs(): Promise<Inputs> { | ||||
|     push: /true/i.test(core.getInput('push')), | ||||
|     outputs: await getInputList('outputs', true), | ||||
|     cacheFrom: await getInputList('cache-from', true), | ||||
|     cacheTo: await getInputList('cache-to', true) | ||||
|     cacheTo: await getInputList('cache-to', true), | ||||
|     secrets: await getInputList('secrets', true) | ||||
|   }; | ||||
| } | ||||
| 
 | ||||
| @ -87,6 +92,9 @@ async function getBuildArgs(inputs: Inputs, buildxVersion: string): Promise<Arra | ||||
|   await asyncForEach(inputs.cacheTo, async cacheTo => { | ||||
|     args.push('--cache-to', cacheTo); | ||||
|   }); | ||||
|   await asyncForEach(inputs.secrets, async secret => { | ||||
|     args.push('--secret', await buildx.getSecret(secret)); | ||||
|   }); | ||||
|   if (inputs.file) { | ||||
|     args.push('--file', inputs.file); | ||||
|   } | ||||
|  | ||||
							
								
								
									
										22
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/main.ts
									
									
									
									
									
								
							| @ -1,6 +1,8 @@ | ||||
| import * as fs from 'fs'; | ||||
| import * as os from 'os'; | ||||
| import * as buildx from './buildx'; | ||||
| import {Inputs, getInputs, getArgs} from './context'; | ||||
| import * as context from './context'; | ||||
| import * as stateHelper from './state-helper'; | ||||
| import * as core from '@actions/core'; | ||||
| import * as exec from '@actions/exec'; | ||||
| 
 | ||||
| @ -15,18 +17,19 @@ async function run(): Promise<void> { | ||||
|       core.setFailed(`Buildx is required. See https://github.com/docker/setup-buildx-action to set up buildx.`); | ||||
|       return; | ||||
|     } | ||||
|     stateHelper.setTmpDir(context.tmpDir); | ||||
| 
 | ||||
|     const buildxVersion = await buildx.getVersion(); | ||||
|     core.info(`📣 Buildx version: ${buildxVersion}`); | ||||
| 
 | ||||
|     let inputs: Inputs = await getInputs(); | ||||
|     let inputs: context.Inputs = await context.getInputs(); | ||||
|     if (inputs.builder) { | ||||
|       core.info(`📌 Using builder instance ${inputs.builder}`); | ||||
|       await buildx.use(inputs.builder); | ||||
|     } | ||||
| 
 | ||||
|     core.info(`🏃 Starting build...`); | ||||
|     const args: string[] = await getArgs(inputs, buildxVersion); | ||||
|     const args: string[] = await context.getArgs(inputs, buildxVersion); | ||||
|     await exec.exec('docker', args); | ||||
| 
 | ||||
|     const imageID = await buildx.getImageID(); | ||||
| @ -40,4 +43,15 @@ async function run(): Promise<void> { | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| run(); | ||||
| async function cleanup(): Promise<void> { | ||||
|   if (stateHelper.tmpDir.length > 0) { | ||||
|     core.info(`🚿 Removing temp folder ${stateHelper.tmpDir}`); | ||||
|     fs.rmdirSync(stateHelper.tmpDir, {recursive: true}); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| if (!stateHelper.IsPost) { | ||||
|   run(); | ||||
| } else { | ||||
|   cleanup(); | ||||
| } | ||||
|  | ||||
							
								
								
									
										12
									
								
								src/state-helper.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/state-helper.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| import * as core from '@actions/core'; | ||||
| 
 | ||||
| export const IsPost = !!process.env['STATE_isPost']; | ||||
| export const tmpDir = process.env['STATE_tmpDir'] || ''; | ||||
| 
 | ||||
| export function setTmpDir(tmpDir: string) { | ||||
|   core.saveState('tmpDir', tmpDir); | ||||
| } | ||||
| 
 | ||||
| if (!IsPost) { | ||||
|   core.saveState('isPost', 'true'); | ||||
| } | ||||
							
								
								
									
										146
									
								
								yarn.lock
									
									
									
									
									
								
							
							
						
						
									
										146
									
								
								yarn.lock
									
									
									
									
									
								
							| @ -14,6 +14,23 @@ | ||||
|   dependencies: | ||||
|     "@actions/io" "^1.0.1" | ||||
| 
 | ||||
| "@actions/github@^4.0.0": | ||||
|   version "4.0.0" | ||||
|   resolved "https://registry.yarnpkg.com/@actions/github/-/github-4.0.0.tgz#d520483151a2bf5d2dc9cd0f20f9ac3a2e458816" | ||||
|   integrity sha512-Ej/Y2E+VV6sR9X7pWL5F3VgEWrABaT292DRqRU6R4hnQjPtC/zD3nagxVdXWiRQvYDh8kHXo7IDmG42eJ/dOMA== | ||||
|   dependencies: | ||||
|     "@actions/http-client" "^1.0.8" | ||||
|     "@octokit/core" "^3.0.0" | ||||
|     "@octokit/plugin-paginate-rest" "^2.2.3" | ||||
|     "@octokit/plugin-rest-endpoint-methods" "^4.0.0" | ||||
| 
 | ||||
| "@actions/http-client@^1.0.8": | ||||
|   version "1.0.8" | ||||
|   resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.8.tgz#8bd76e8eca89dc8bcf619aa128eba85f7a39af45" | ||||
|   integrity sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA== | ||||
|   dependencies: | ||||
|     tunnel "0.0.6" | ||||
| 
 | ||||
| "@actions/io@^1.0.1": | ||||
|   version "1.0.2" | ||||
|   resolved "https://registry.yarnpkg.com/@actions/io/-/io-1.0.2.tgz#2f614b6e69ce14d191180451eb38e6576a6e6b27" | ||||
| @ -485,6 +502,88 @@ | ||||
|     "@types/yargs" "^15.0.0" | ||||
|     chalk "^4.0.0" | ||||
| 
 | ||||
| "@octokit/auth-token@^2.4.0": | ||||
|   version "2.4.2" | ||||
|   resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.2.tgz#10d0ae979b100fa6b72fa0e8e63e27e6d0dbff8a" | ||||
|   integrity sha512-jE/lE/IKIz2v1+/P0u4fJqv0kYwXOTujKemJMFr6FeopsxlIK3+wKDCJGnysg81XID5TgZQbIfuJ5J0lnTiuyQ== | ||||
|   dependencies: | ||||
|     "@octokit/types" "^5.0.0" | ||||
| 
 | ||||
| "@octokit/core@^3.0.0": | ||||
|   version "3.1.2" | ||||
|   resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.1.2.tgz#c937d5f9621b764573068fcd2e5defcc872fd9cc" | ||||
|   integrity sha512-AInOFULmwOa7+NFi9F8DlDkm5qtZVmDQayi7TUgChE3yeIGPq0Y+6cAEXPexQ3Ea+uZy66hKEazR7DJyU+4wfw== | ||||
|   dependencies: | ||||
|     "@octokit/auth-token" "^2.4.0" | ||||
|     "@octokit/graphql" "^4.3.1" | ||||
|     "@octokit/request" "^5.4.0" | ||||
|     "@octokit/types" "^5.0.0" | ||||
|     before-after-hook "^2.1.0" | ||||
|     universal-user-agent "^6.0.0" | ||||
| 
 | ||||
| "@octokit/endpoint@^6.0.1": | ||||
|   version "6.0.5" | ||||
|   resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.5.tgz#43a6adee813c5ffd2f719e20cfd14a1fee7c193a" | ||||
|   integrity sha512-70K5u6zd45ItOny6aHQAsea8HHQjlQq85yqOMe+Aj8dkhN2qSJ9T+Q3YjUjEYfPRBcuUWNgMn62DQnP/4LAIiQ== | ||||
|   dependencies: | ||||
|     "@octokit/types" "^5.0.0" | ||||
|     is-plain-object "^4.0.0" | ||||
|     universal-user-agent "^6.0.0" | ||||
| 
 | ||||
| "@octokit/graphql@^4.3.1": | ||||
|   version "4.5.4" | ||||
|   resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.5.4.tgz#c9ef75b0406ebf195bf5f4ed2304a77ed7df27c7" | ||||
|   integrity sha512-ITpZ+dQc0cXAW1FmDkHJJM+8Lb6anUnin0VB5hLBilnYVdLC0ICFU/KIvT7OXfW9S81DE3U4Vx2EypDG1OYaPA== | ||||
|   dependencies: | ||||
|     "@octokit/request" "^5.3.0" | ||||
|     "@octokit/types" "^5.0.0" | ||||
|     universal-user-agent "^6.0.0" | ||||
| 
 | ||||
| "@octokit/plugin-paginate-rest@^2.2.3": | ||||
|   version "2.3.1" | ||||
|   resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.3.1.tgz#00f91701dfda26227c3e748d42bc89e2d0d9ce55" | ||||
|   integrity sha512-81A+ONLpcSX7vWxnEmVZteQPNsbdeScSVUqjgMYPSk1trzG69iYkhS42wPRWtN0nYw6OEmT48DNeQCjHeyroYw== | ||||
|   dependencies: | ||||
|     "@octokit/types" "^5.3.0" | ||||
| 
 | ||||
| "@octokit/plugin-rest-endpoint-methods@^4.0.0": | ||||
|   version "4.1.3" | ||||
|   resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.1.3.tgz#44d9af35cd9fef63c7a4cf3b0e6b681886cc8d34" | ||||
|   integrity sha512-az3seq9yuc0OXlNLrZ0fWTNbFuL4sN8GN1sLmovELg3+LnpWmOs3GAn2KGa6E7SKMgpCuFvJwvsHEfYasTHUxQ== | ||||
|   dependencies: | ||||
|     "@octokit/types" "^5.1.1" | ||||
|     deprecation "^2.3.1" | ||||
| 
 | ||||
| "@octokit/request-error@^2.0.0": | ||||
|   version "2.0.2" | ||||
|   resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.0.2.tgz#0e76b83f5d8fdda1db99027ea5f617c2e6ba9ed0" | ||||
|   integrity sha512-2BrmnvVSV1MXQvEkrb9zwzP0wXFNbPJij922kYBTLIlIafukrGOb+ABBT2+c6wZiuyWDH1K1zmjGQ0toN/wMWw== | ||||
|   dependencies: | ||||
|     "@octokit/types" "^5.0.1" | ||||
|     deprecation "^2.0.0" | ||||
|     once "^1.4.0" | ||||
| 
 | ||||
| "@octokit/request@^5.3.0", "@octokit/request@^5.4.0": | ||||
|   version "5.4.7" | ||||
|   resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.4.7.tgz#fd703ee092e0463ceba49ff7a3e61cb4cf8a0fde" | ||||
|   integrity sha512-FN22xUDP0i0uF38YMbOfx6TotpcENP5W8yJM1e/LieGXn6IoRxDMnBf7tx5RKSW4xuUZ/1P04NFZy5iY3Rax1A== | ||||
|   dependencies: | ||||
|     "@octokit/endpoint" "^6.0.1" | ||||
|     "@octokit/request-error" "^2.0.0" | ||||
|     "@octokit/types" "^5.0.0" | ||||
|     deprecation "^2.0.0" | ||||
|     is-plain-object "^4.0.0" | ||||
|     node-fetch "^2.3.0" | ||||
|     once "^1.4.0" | ||||
|     universal-user-agent "^6.0.0" | ||||
| 
 | ||||
| "@octokit/types@^5.0.0", "@octokit/types@^5.0.1", "@octokit/types@^5.1.1", "@octokit/types@^5.3.0": | ||||
|   version "5.4.1" | ||||
|   resolved "https://registry.yarnpkg.com/@octokit/types/-/types-5.4.1.tgz#d5d5f2b70ffc0e3f89467c3db749fa87fc3b7031" | ||||
|   integrity sha512-OlMlSySBJoJ6uozkr/i03nO5dlYQyE05vmQNZhAh9MyO4DPBP88QlwsDVLmVjIMFssvIZB6WO0ctIGMRG+xsJQ== | ||||
|   dependencies: | ||||
|     "@types/node" ">= 8" | ||||
| 
 | ||||
| "@sinonjs/commons@^1.7.0": | ||||
|   version "1.8.1" | ||||
|   resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.1.tgz#e7df00f98a203324f6dc7cc606cad9d4a8ab2217" | ||||
| @ -584,6 +683,11 @@ | ||||
|   resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.27.tgz#a151873af5a5e851b51b3b065c9e63390a9e0eb1" | ||||
|   integrity sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g== | ||||
| 
 | ||||
| "@types/node@>= 8": | ||||
|   version "14.6.2" | ||||
|   resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.2.tgz#264b44c5a28dfa80198fc2f7b6d3c8a054b9491f" | ||||
|   integrity sha512-onlIwbaeqvZyniGPfdw/TEhKIh79pz66L1q06WUQqJLnAb6wbjvOtepLYTGHTqzdXgBYIE3ZdmqHDGsRsbBz7A== | ||||
| 
 | ||||
| "@types/normalize-package-data@^2.4.0": | ||||
|   version "2.4.0" | ||||
|   resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" | ||||
| @ -599,6 +703,11 @@ | ||||
|   resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" | ||||
|   integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw== | ||||
| 
 | ||||
| "@types/tmp@^0.2.0": | ||||
|   version "0.2.0" | ||||
|   resolved "https://registry.yarnpkg.com/@types/tmp/-/tmp-0.2.0.tgz#e3f52b4d7397eaa9193592ef3fdd44dc0af4298c" | ||||
|   integrity sha512-flgpHJjntpBAdJD43ShRosQvNC0ME97DCfGvZEDlAThQmnerRXrLbX6YgzRBQCZTthET9eAWFAMaYP0m0Y4HzQ== | ||||
| 
 | ||||
| "@types/yargs-parser@*": | ||||
|   version "15.0.0" | ||||
|   resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-15.0.0.tgz#cb3f9f741869e20cce330ffbeb9271590483882d" | ||||
| @ -841,6 +950,11 @@ bcrypt-pbkdf@^1.0.0: | ||||
|   dependencies: | ||||
|     tweetnacl "^0.14.3" | ||||
| 
 | ||||
| before-after-hook@^2.1.0: | ||||
|   version "2.1.0" | ||||
|   resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635" | ||||
|   integrity sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A== | ||||
| 
 | ||||
| brace-expansion@^1.1.7: | ||||
|   version "1.1.11" | ||||
|   resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" | ||||
| @ -1202,6 +1316,11 @@ delayed-stream@~1.0.0: | ||||
|   resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" | ||||
|   integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= | ||||
| 
 | ||||
| deprecation@^2.0.0, deprecation@^2.3.1: | ||||
|   version "2.3.1" | ||||
|   resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" | ||||
|   integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ== | ||||
| 
 | ||||
| detect-newline@^3.0.0: | ||||
|   version "3.1.0" | ||||
|   resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" | ||||
| @ -1798,6 +1917,11 @@ is-plain-object@^2.0.3, is-plain-object@^2.0.4: | ||||
|   dependencies: | ||||
|     isobject "^3.0.1" | ||||
| 
 | ||||
| is-plain-object@^4.0.0: | ||||
|   version "4.1.1" | ||||
|   resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-4.1.1.tgz#1a14d6452cbd50790edc7fdaa0aed5a40a35ebb5" | ||||
|   integrity sha512-5Aw8LLVsDlZsETVMhoMXzqsXwQqr/0vlnBYzIXJbYo2F4yYlhLHs+Ez7Bod7IIQKWkJbJfxrWD7pA1Dw1TKrwA== | ||||
| 
 | ||||
| is-potential-custom-element-name@^1.0.0: | ||||
|   version "1.0.0" | ||||
|   resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.0.tgz#0c52e54bcca391bb2c494b21e8626d7336c6e397" | ||||
| @ -2620,6 +2744,11 @@ nice-try@^1.0.4: | ||||
|   resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" | ||||
|   integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== | ||||
| 
 | ||||
| node-fetch@^2.3.0: | ||||
|   version "2.6.0" | ||||
|   resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" | ||||
|   integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== | ||||
| 
 | ||||
| node-int64@^0.4.0: | ||||
|   version "0.4.0" | ||||
|   resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" | ||||
| @ -3399,6 +3528,13 @@ throat@^5.0.0: | ||||
|   resolved "https://registry.yarnpkg.com/throat/-/throat-5.0.0.tgz#c5199235803aad18754a667d659b5e72ce16764b" | ||||
|   integrity sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA== | ||||
| 
 | ||||
| tmp@^0.2.1: | ||||
|   version "0.2.1" | ||||
|   resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14" | ||||
|   integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ== | ||||
|   dependencies: | ||||
|     rimraf "^3.0.0" | ||||
| 
 | ||||
| tmpl@1.0.x: | ||||
|   version "1.0.4" | ||||
|   resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1" | ||||
| @ -3489,6 +3625,11 @@ tunnel-agent@^0.6.0: | ||||
|   dependencies: | ||||
|     safe-buffer "^5.0.1" | ||||
| 
 | ||||
| tunnel@0.0.6: | ||||
|   version "0.0.6" | ||||
|   resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" | ||||
|   integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg== | ||||
| 
 | ||||
| tweetnacl@^0.14.3, tweetnacl@~0.14.0: | ||||
|   version "0.14.5" | ||||
|   resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" | ||||
| @ -3551,6 +3692,11 @@ union-value@^1.0.0: | ||||
|     is-extendable "^0.1.1" | ||||
|     set-value "^2.0.1" | ||||
| 
 | ||||
| universal-user-agent@^6.0.0: | ||||
|   version "6.0.0" | ||||
|   resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee" | ||||
|   integrity sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w== | ||||
| 
 | ||||
| unset-value@^1.0.0: | ||||
|   version "1.0.0" | ||||
|   resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user