Compare commits
	
		
			56 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | e1b7f96249 | ||
|   | 5a4a26c0fc | ||
|   | 8891861577 | ||
|   | f6a733366a | ||
|   | eb4f14646c | ||
|   | 646552f0a1 | ||
|   | 2ec8f1d346 | ||
|   | 8f5c91aad9 | ||
|   | 6a12baa867 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | da940a9403 | ||
|   | 9cf6eb2b16 | ||
|   | 3c2d8e5269 | ||
|   | d693655c74 | ||
|   | bfea497a8e | ||
|   | 8ca2ca55d4 | ||
|   | 460e0e47f5 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | edb2e175f1 | ||
|   | 09f8407c80 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 614833a85f | ||
|   | 0ec1157bb5 | ||
|   | 22d49d64f5 | ||
|   | 9379083e42 | ||
|   | a63b18dea2 | ||
|   | af867d4937 | ||
|   | 33eec1587d | ||
|   | 3db4797dd2 | ||
|   | 659fcba376 | ||
|   | 080cadd33e | ||
|   | dc4c1fca8b | ||
|   | b280b0485b | ||
|   | b87564a5cc | ||
|   | d2bc6a5d16 | ||
|   | e5f26cdae4 | ||
|   | 616efcd405 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 0539e1a717 | ||
|   | 636b4540ec | ||
|   | af932bfb2e | ||
|   | 2db03de115 | ||
|   | 4643aec7c4 | ||
|   | 4a531fa5a6 | ||
|   | 565d16e074 | ||
|   | c473874c2c | ||
|   | b94cedd686 | ||
|   | 76c8b42a58 | ||
|   | 920f0da143 | ||
|   | e723b420bf | ||
|   | f9deaa080c | ||
|   | b4c22c3e33 | ||
|   | a8587cb818 | ||
|   | f2a733f179 | ||
|   | 35ab0dd217 | ||
|   | 46d5afd128 | ||
|   | a8bb35be5a | ||
|   | 5c278cd8ab | ||
|   | 3b98ff3c03 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 6b88c3e647 | 
| @@ -1 +1,2 @@ | ||||
| node_modules | ||||
| /coverage | ||||
| /node_modules | ||||
|   | ||||
							
								
								
									
										35
									
								
								.github/CONTRIBUTING.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										35
									
								
								.github/CONTRIBUTING.md
									
									
									
									
										vendored
									
									
								
							| @@ -2,33 +2,20 @@ | ||||
|  | ||||
| Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great. | ||||
|  | ||||
| Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE). | ||||
| Contributions to this project are [released](https://docs.github.com/en/github/site-policy/github-terms-of-service#6-contributions-under-repository-license) | ||||
| to the public under the [project's open source license](LICENSE). | ||||
|  | ||||
| ## Submitting a pull request | ||||
|  | ||||
| 1. [Fork](https://github.com/docker/build-push-action/fork) and clone the repository | ||||
| 2. Configure and install the dependencies: `yarn install` | ||||
| 3. Make sure the tests pass on your machine: `yarn run test` | ||||
| 4. Create a new branch: `git checkout -b my-branch-name` | ||||
| 5. Make your change, add tests, and make sure the tests still pass | ||||
| 6. Run pre-checkin: `yarn run pre-checkin` | ||||
| 7. Push to your fork and [submit a pull request](https://github.com/docker/build-push-action/compare) | ||||
| 8. Pat your self on the back and wait for your pull request to be reviewed and merged. | ||||
|  | ||||
| ## Container based developer flow | ||||
|  | ||||
| If you don't want to maintain a Node developer environment that fits this project you can use containerized commands instead of invoking yarn directly. | ||||
|  | ||||
| ``` | ||||
| # format code and build javascript artifacts | ||||
| docker buildx bake pre-checkin | ||||
|  | ||||
| # validate all code has correctly formatted and built | ||||
| docker buildx bake validate | ||||
|  | ||||
| # run tests | ||||
| docker buildx bake test | ||||
| ``` | ||||
| 3. Create a new branch: `git checkout -b my-branch-name` | ||||
| 4. Make your changes | ||||
| 5. Make sure the tests pass: `docker buildx bake test` | ||||
| 6. Format code and build javascript artifacts: `docker buildx bake pre-checkin` | ||||
| 7. Validate all code has correctly formatted and built: `docker buildx bake validate` | ||||
| 8. Push to your fork and [submit a pull request](https://github.com/docker/build-push-action/compare) | ||||
| 9. Pat your self on the back and wait for your pull request to be reviewed and merged. | ||||
|  | ||||
| Here are a few things you can do that will increase the likelihood of your pull request being accepted: | ||||
|  | ||||
| @@ -40,5 +27,5 @@ Here are a few things you can do that will increase the likelihood of your pull | ||||
| ## Resources | ||||
|  | ||||
| - [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/) | ||||
| - [Using Pull Requests](https://help.github.com/articles/about-pull-requests/) | ||||
| - [GitHub Help](https://help.github.com) | ||||
| - [Using Pull Requests](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests) | ||||
| - [GitHub Help](https://docs.github.com/en) | ||||
|   | ||||
							
								
								
									
										2
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/ISSUE_TEMPLATE/bug_report.md
									
									
									
									
										vendored
									
									
								
							| @@ -34,4 +34,4 @@ Before sumbitting a bug report please read the [Troubleshooting doc](https://git | ||||
|  | ||||
| ### Logs | ||||
|  | ||||
| > Download the [log file of your build](https://help.github.com/en/actions/configuring-and-managing-workflows/managing-a-workflow-run#downloading-logs) and [attach it](https://help.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue. | ||||
| > Download the [log file of your build](https://docs.github.com/en/actions/managing-workflow-runs/using-workflow-run-logs#downloading-logs) and [attach it](https://docs.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests) to this issue. | ||||
|   | ||||
							
								
								
									
										79
									
								
								.github/labels.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										79
									
								
								.github/labels.yml
									
									
									
									
										vendored
									
									
								
							| @@ -1,79 +0,0 @@ | ||||
| ## more info https://github.com/crazy-max/ghaction-github-labeler | ||||
| - # automerge | ||||
|   name: ":bell: automerge" | ||||
|   color: "8f4fbc" | ||||
|   description: "" | ||||
| - # bot | ||||
|   name: ":robot: bot" | ||||
|   color: "69cde9" | ||||
|   description: "" | ||||
| - # bug | ||||
|   name: ":bug: bug" | ||||
|   color: "b60205" | ||||
|   description: "" | ||||
| - # dependencies | ||||
|   name: ":game_die: dependencies" | ||||
|   color: "0366d6" | ||||
|   description: "" | ||||
|   from_name: "dependencies" | ||||
| - # documentation | ||||
|   name: ":memo: documentation" | ||||
|   color: "c5def5" | ||||
|   description: "" | ||||
| - # duplicate | ||||
|   name: ":busts_in_silhouette: duplicate" | ||||
|   color: "cccccc" | ||||
|   description: "" | ||||
| - # enhancement | ||||
|   name: ":sparkles: enhancement" | ||||
|   color: "0054ca" | ||||
|   description: "" | ||||
| - # feature request | ||||
|   name: ":bulb: feature request" | ||||
|   color: "0e8a16" | ||||
|   description: "" | ||||
| - # feedback | ||||
|   name: ":mega: feedback" | ||||
|   color: "03a9f4" | ||||
|   description: "" | ||||
| - # future maybe | ||||
|   name: ":rocket: future maybe" | ||||
|   color: "fef2c0" | ||||
|   description: "" | ||||
| - # good first issue | ||||
|   name: ":hatching_chick: good first issue" | ||||
|   color: "7057ff" | ||||
|   description: "" | ||||
| - # help wanted | ||||
|   name: ":pray: help wanted" | ||||
|   color: "4caf50" | ||||
|   description: "" | ||||
| - # hold | ||||
|   name: ":hand: hold" | ||||
|   color: "24292f" | ||||
|   description: "" | ||||
| - # invalid | ||||
|   name: ":no_entry_sign: invalid" | ||||
|   color: "e6e6e6" | ||||
|   description: "" | ||||
| - # maybe bug | ||||
|   name: ":interrobang: maybe bug" | ||||
|   color: "ff5722" | ||||
|   description: "" | ||||
| - # needs more info | ||||
|   name: ":thinking: needs more info" | ||||
|   color: "795548" | ||||
|   description: "" | ||||
| - # question | ||||
|   name: ":question: question" | ||||
|   color: "3f51b5" | ||||
|   description: "" | ||||
|   from_name: "question" | ||||
| - # upstream | ||||
|   name: ":eyes: upstream" | ||||
|   color: "fbca04" | ||||
|   description: "" | ||||
| - # wontfix | ||||
|   name: ":coffin: wontfix" | ||||
|   color: "ffffff" | ||||
|   description: "" | ||||
							
								
								
									
										54
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										54
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							| @@ -244,12 +244,6 @@ jobs: | ||||
|  | ||||
|   docker-driver: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         push: | ||||
|           - true | ||||
|           - false | ||||
|     services: | ||||
|       registry: | ||||
|         image: registry:2 | ||||
| @@ -262,24 +256,12 @@ jobs: | ||||
|       - | ||||
|         name: Build | ||||
|         id: docker_build | ||||
|         continue-on-error: ${{ matrix.push }} | ||||
|         uses: ./ | ||||
|         with: | ||||
|           context: ./test | ||||
|           file: ./test/Dockerfile | ||||
|           push: ${{ matrix.push }} | ||||
|           push: true | ||||
|           tags: localhost:5000/name/app:latest | ||||
|       - | ||||
|         name: Check | ||||
|         run: | | ||||
|           echo "${{ toJson(steps.docker_build) }}" | ||||
|           if [ "${{ matrix.push }}" = "false" ]; then | ||||
|             exit 0 | ||||
|           fi | ||||
|           if [ "${{ steps.docker_build.outcome }}" != "failure" ] || [ "${{ steps.docker_build.conclusion }}" != "success" ]; then | ||||
|             echo "::error::Should have failed" | ||||
|             exit 1 | ||||
|           fi | ||||
|       - | ||||
|         name: Dump context | ||||
|         if: always() | ||||
| @@ -308,6 +290,30 @@ jobs: | ||||
|         if: always() | ||||
|         uses: crazy-max/ghaction-dump-context@v1 | ||||
|  | ||||
|   network: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|       - | ||||
|         name: List networks | ||||
|         run: docker network ls | ||||
|       - | ||||
|         name: Build | ||||
|         uses: ./ | ||||
|         with: | ||||
|           context: ./test | ||||
|           tags: name/app:latest | ||||
|           network: host | ||||
|       - | ||||
|         name: Dump context | ||||
|         if: always() | ||||
|         uses: crazy-max/ghaction-dump-context@v1 | ||||
|  | ||||
|   multi: | ||||
|     runs-on: ubuntu-latest | ||||
|     strategy: | ||||
| @@ -344,7 +350,7 @@ jobs: | ||||
|         uses: ./ | ||||
|         with: | ||||
|           context: ./test | ||||
|           file: ./test/Dockerfile-${{ matrix.dockerfile }} | ||||
|           file: ./test/${{ matrix.dockerfile }}.Dockerfile | ||||
|           builder: ${{ steps.buildx.outputs.name }} | ||||
|           platforms: linux/amd64,linux/arm64 | ||||
|           push: true | ||||
| @@ -397,7 +403,7 @@ jobs: | ||||
|         uses: ./ | ||||
|         with: | ||||
|           context: ./test | ||||
|           file: ./test/Dockerfile-multi | ||||
|           file: ./test/multi.Dockerfile | ||||
|           builder: ${{ steps.buildx.outputs.name }} | ||||
|           platforms: linux/amd64,linux/arm64 | ||||
|           push: true | ||||
| @@ -430,7 +436,7 @@ jobs: | ||||
|         uses: ./ | ||||
|         with: | ||||
|           context: ./test | ||||
|           file: ./test/Dockerfile-multi | ||||
|           file: ./test/multi.Dockerfile | ||||
|           builder: ${{ steps.buildx.outputs.name }} | ||||
|           platforms: linux/amd64,linux/arm64 | ||||
|           push: true | ||||
| @@ -507,7 +513,7 @@ jobs: | ||||
|         uses: ./ | ||||
|         with: | ||||
|           context: ./test | ||||
|           file: ./test/Dockerfile-multi | ||||
|           file: ./test/multi.Dockerfile | ||||
|           builder: ${{ steps.buildx.outputs.name }} | ||||
|           platforms: linux/amd64,linux/arm64 | ||||
|           push: true | ||||
| @@ -572,7 +578,7 @@ jobs: | ||||
|         uses: ./ | ||||
|         with: | ||||
|           context: ./test | ||||
|           file: ./test/Dockerfile-multi | ||||
|           file: ./test/multi.Dockerfile | ||||
|           builder: ${{ steps.buildx.outputs.name }} | ||||
|           platforms: linux/amd64,linux/arm64 | ||||
|           push: true | ||||
|   | ||||
							
								
								
									
										38
									
								
								.github/workflows/e2e.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										38
									
								
								.github/workflows/e2e.yml
									
									
									
									
										vendored
									
									
								
							| @@ -32,14 +32,34 @@ jobs: | ||||
|             slug: registry.gitlab.com/test1716/test | ||||
|             username_secret: GITLAB_USERNAME | ||||
|             password_secret: GITLAB_TOKEN | ||||
|           - | ||||
|             registry: 175142243308.dkr.ecr.us-east-2.amazonaws.com | ||||
|             slug: 175142243308.dkr.ecr.us-east-2.amazonaws.com/sandbox/test-docker-action | ||||
|             username_secret: AWS_ACCESS_KEY_ID | ||||
|             password_secret: AWS_SECRET_ACCESS_KEY | ||||
|           - | ||||
|             registry: public.ecr.aws | ||||
|             slug: public.ecr.aws/q3b5f1u4/test-docker-action | ||||
|             username_secret: AWS_ACCESS_KEY_ID | ||||
|             password_secret: AWS_SECRET_ACCESS_KEY | ||||
|           - | ||||
|             registry: us-east4-docker.pkg.dev | ||||
|             slug: us-east4-docker.pkg.dev/sandbox-298914/docker-official-github-actions/test-docker-action | ||||
|             username_secret: GAR_USERNAME | ||||
|             password_secret: GAR_JSON_KEY | ||||
|           - | ||||
|             registry: gcr.io | ||||
|             slug: gcr.io/sandbox-298914/test-docker-action | ||||
|             username_secret: GCR_USERNAME | ||||
|             password_secret: GCR_JSON_KEY | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Docker meta | ||||
|         id: docker_meta | ||||
|         uses: crazy-max/ghaction-docker-meta@v1 | ||||
|         id: meta | ||||
|         uses: crazy-max/ghaction-docker-meta@v2 | ||||
|         with: | ||||
|           images: ${{ matrix.slug }} | ||||
|       - | ||||
| @@ -61,22 +81,24 @@ jobs: | ||||
|         uses: ./ | ||||
|         with: | ||||
|           context: ./test | ||||
|           file: ./test/Dockerfile-multi | ||||
|           file: ./test/multi.Dockerfile | ||||
|           platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x | ||||
|           push: ${{ github.event_name != 'pull_request' }} | ||||
|           tags: ${{ steps.docker_meta.outputs.tags }} | ||||
|           labels: ${{ steps.docker_meta.outputs.labels }} | ||||
|           tags: ${{ steps.meta.outputs.tags }} | ||||
|           labels: ${{ steps.meta.outputs.labels }} | ||||
|           cache-from: type=registry,ref=${{ matrix.slug }}:master | ||||
|           cache-to: type=inline | ||||
|       - | ||||
|         name: Inspect image | ||||
|         if: github.event_name != 'pull_request' | ||||
|         run: | | ||||
|           docker pull ${{ matrix.slug }}:${{ steps.docker_meta.outputs.version }} | ||||
|           docker image inspect ${{ matrix.slug }}:${{ steps.docker_meta.outputs.version }} | ||||
|           docker pull ${{ matrix.slug }}:${{ steps.meta.outputs.version }} | ||||
|           docker image inspect ${{ matrix.slug }}:${{ steps.meta.outputs.version }} | ||||
|       - | ||||
|         name: Check manifest | ||||
|         if: github.event_name != 'pull_request' | ||||
|         run: | | ||||
|           docker buildx imagetools inspect ${{ matrix.slug }}:${{ steps.docker_meta.outputs.version }} | ||||
|           docker buildx imagetools inspect ${{ matrix.slug }}:${{ steps.meta.outputs.version }} | ||||
|       - | ||||
|         name: Dump context | ||||
|         if: always() | ||||
|   | ||||
							
								
								
									
										27
									
								
								.github/workflows/example.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										27
									
								
								.github/workflows/example.yml
									
									
									
									
										vendored
									
									
								
							| @@ -28,11 +28,18 @@ jobs: | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Docker meta | ||||
|         id: docker_meta | ||||
|         uses: crazy-max/ghaction-docker-meta@v1 | ||||
|         id: meta | ||||
|         uses: crazy-max/ghaction-docker-meta@v2 | ||||
|         with: | ||||
|           images: ${{ env.DOCKER_IMAGE }} # list of Docker images to use as base name for tags | ||||
|           tag-sha: true # add git short SHA as Docker tag | ||||
|           images: ${{ env.DOCKER_IMAGE }} | ||||
|           tags: | | ||||
|             type=schedule | ||||
|             type=ref,event=branch | ||||
|             type=ref,event=pr | ||||
|             type=semver,pattern={{version}} | ||||
|             type=semver,pattern={{major}}.{{minor}} | ||||
|             type=semver,pattern={{major}} | ||||
|             type=sha | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
| @@ -45,8 +52,8 @@ jobs: | ||||
|           context: ./test | ||||
|           file: ./test/Dockerfile | ||||
|           load: true | ||||
|           tags: ${{ steps.docker_meta.outputs.tags }} | ||||
|           labels: ${{ steps.docker_meta.outputs.labels }} | ||||
|           tags: ${{ steps.meta.outputs.tags }} | ||||
|           labels: ${{ steps.meta.outputs.labels }} | ||||
|       - | ||||
|         name: Build and push to local registry | ||||
|         uses: ./ | ||||
| @@ -54,17 +61,17 @@ jobs: | ||||
|           context: ./test | ||||
|           file: ./test/Dockerfile | ||||
|           push: ${{ github.event_name != 'pull_request' }} | ||||
|           tags: ${{ steps.docker_meta.outputs.tags }} | ||||
|           labels: ${{ steps.docker_meta.outputs.labels }} | ||||
|           tags: ${{ steps.meta.outputs.tags }} | ||||
|           labels: ${{ steps.meta.outputs.labels }} | ||||
|       - | ||||
|         name: Inspect image | ||||
|         run: | | ||||
|           docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} | ||||
|           docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} | ||||
|       - | ||||
|         name: Check manifest | ||||
|         if: github.event_name != 'pull_request' | ||||
|         run: | | ||||
|           docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }} | ||||
|           docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }} | ||||
|       - | ||||
|         name: Dump context | ||||
|         if: always() | ||||
|   | ||||
							
								
								
									
										20
									
								
								.github/workflows/labels.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								.github/workflows/labels.yml
									
									
									
									
										vendored
									
									
								
							| @@ -1,20 +0,0 @@ | ||||
| name: labels | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - 'master' | ||||
|     paths: | ||||
|       - '.github/labels.yml' | ||||
|       - '.github/workflows/labels.yml' | ||||
|  | ||||
| jobs: | ||||
|   labeler: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Run Labeler | ||||
|         uses: crazy-max/ghaction-github-labeler@v3 | ||||
							
								
								
									
										29
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										29
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							| @@ -3,25 +3,12 @@ name: test | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - master | ||||
|       - 'master' | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - master | ||||
|       - 'master' | ||||
|  | ||||
| jobs: | ||||
|   test-containerized: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Validate | ||||
|         run: docker buildx bake validate | ||||
|       - | ||||
|         name: Test | ||||
|         run: docker buildx bake test | ||||
|  | ||||
|   test: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
| @@ -29,15 +16,17 @@ jobs: | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Install | ||||
|         run: yarn install | ||||
|         name: Validate | ||||
|         uses: docker/bake-action@v1 | ||||
|         with: | ||||
|           targets: validate | ||||
|       - | ||||
|         name: Test | ||||
|         run: yarn run test | ||||
|         uses: docker/bake-action@v1 | ||||
|         with: | ||||
|           targets: test | ||||
|       - | ||||
|         name: Upload coverage | ||||
|         uses: codecov/codecov-action@v1 | ||||
|         if: success() | ||||
|         with: | ||||
|           token: ${{ secrets.CODECOV_TOKEN }} | ||||
|           file: ./coverage/clover.xml | ||||
|   | ||||
							
								
								
									
										38
									
								
								.github/workflows/virtual-env.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								.github/workflows/virtual-env.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| name: virtual-env | ||||
|  | ||||
| on: | ||||
|   workflow_dispatch: | ||||
|   schedule: | ||||
|     - cron: '0 10 * * *' # everyday at 10am | ||||
|  | ||||
| jobs: | ||||
|   os: | ||||
|     runs-on: ${{ matrix.os }} | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: | ||||
|           - ubuntu-latest | ||||
|           - ubuntu-20.04 | ||||
|           - ubuntu-18.04 | ||||
|           - ubuntu-16.04 | ||||
|     steps: | ||||
|       - | ||||
|         name: List install packages | ||||
|         run: apt list --installed | ||||
|       - | ||||
|         name: Docker info | ||||
|         run: docker info | ||||
|       - | ||||
|         name: Docker version | ||||
|         run: docker version | ||||
|       - | ||||
|         name: buildx version | ||||
|         run: docker buildx version | ||||
|       - | ||||
|         name: containerd version | ||||
|         run: containerd --version | ||||
|       - | ||||
|         name: Dump context | ||||
|         if: always() | ||||
|         uses: crazy-max/ghaction-dump-context@v1 | ||||
							
								
								
									
										52
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										52
									
								
								Dockerfile
									
									
									
									
									
								
							| @@ -1,52 +0,0 @@ | ||||
| #syntax=docker/dockerfile:1.1-experimental | ||||
|  | ||||
| FROM node:12 AS deps | ||||
| WORKDIR /src | ||||
| COPY package.json yarn.lock ./ | ||||
| RUN --mount=type=cache,target=/usr/local/share/.cache/yarn \ | ||||
|   yarn install | ||||
|  | ||||
| FROM scratch AS update-yarn | ||||
| COPY --from=deps /src/yarn.lock / | ||||
|  | ||||
| FROM deps AS validate-yarn | ||||
| COPY .git .git | ||||
| RUN status=$(git status --porcelain -- yarn.lock); if [ -n "$status" ]; then echo $status; exit 1; fi | ||||
|  | ||||
| FROM deps AS base | ||||
| COPY . . | ||||
|  | ||||
| FROM base AS build | ||||
| RUN yarn build | ||||
|  | ||||
| FROM deps AS test | ||||
| COPY --from=docker /usr/local/bin/docker /usr/bin/ | ||||
| ARG TARGETOS | ||||
| ARG TARGETARCH | ||||
| ARG BUILDX_VERSION=v0.4.2 | ||||
| ENV RUNNER_TEMP=/tmp/github_runner | ||||
| ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache | ||||
| RUN mkdir -p /usr/local/lib/docker/cli-plugins && \ | ||||
|   curl -fsSL https://github.com/docker/buildx/releases/download/$BUILDX_VERSION/buildx-$BUILDX_VERSION.$TARGETOS-$TARGETARCH > /usr/local/lib/docker/cli-plugins/docker-buildx && \ | ||||
|   chmod +x /usr/local/lib/docker/cli-plugins/docker-buildx && \ | ||||
|   docker buildx version | ||||
| COPY . . | ||||
| RUN yarn run test | ||||
|  | ||||
| FROM base AS run-format | ||||
| RUN yarn run format | ||||
|  | ||||
| FROM scratch AS format | ||||
| COPY --from=run-format /src/src/*.ts /src/ | ||||
|  | ||||
| FROM base AS validate-format | ||||
| RUN yarn run format-check | ||||
|  | ||||
| FROM scratch AS dist | ||||
| COPY --from=build /src/dist/ /dist/ | ||||
|  | ||||
| FROM build AS validate-build | ||||
| RUN status=$(git status --porcelain -- dist); if [ -n "$status" ]; then echo $status; exit 1; fi | ||||
|  | ||||
| FROM base AS dev | ||||
| ENTRYPOINT ["bash"] | ||||
							
								
								
									
										587
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										587
									
								
								README.md
									
									
									
									
									
								
							| @@ -6,23 +6,18 @@ | ||||
|  | ||||
| ## Upgrade from v1 | ||||
|  | ||||
| `v2` of this action includes significant updates and now uses Docker [Buildx](https://github.com/docker/buildx). It | ||||
| works with 3 new actions ([login](https://github.com/docker/login-action), [setup-buildx](https://github.com/docker/setup-buildx-action) | ||||
| and [setup-qemu](https://github.com/docker/setup-qemu-action)) that we have created. It's also rewritten as a | ||||
| [typescript-action](https://github.com/actions/typescript-action/) to be as close as possible of the | ||||
| [GitHub Runner](https://github.com/actions/virtual-environments) during its execution. | ||||
| `v2` of this action includes significant updates and now 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 close as possible | ||||
| of the [GitHub Runner](https://github.com/actions/virtual-environments) during its execution. | ||||
|  | ||||
| [Upgrade notes](UPGRADE.md) and many [usage examples](#usage) have been added to handle most use cases but `v1` is | ||||
| still available through [`releases/v1` branch](https://github.com/docker/build-push-action/tree/releases/v1). | ||||
| [Upgrade notes](UPGRADE.md) with many [usage examples](#advanced-usage) have been added to handle most use cases but | ||||
| `v1` is still available through [`releases/v1` branch](https://github.com/docker/build-push-action/tree/releases/v1). | ||||
|  | ||||
| ## About | ||||
|  | ||||
| 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 | ||||
| > * [setup-buildx](https://github.com/docker/setup-buildx-action) action | ||||
| > * [setup-qemu](https://github.com/docker/setup-qemu-action) action | ||||
| GitHub Action to build and push Docker images with [Buildx](https://github.com/docker/buildx) with full support of the | ||||
| features provided by [Moby BuildKit](https://github.com/moby/buildkit) builder toolkit. This includes multi-platform | ||||
| build, secrets, remote cache, etc. and different builder deployment/namespacing options. | ||||
|  | ||||
|  | ||||
|  | ||||
| @@ -31,46 +26,58 @@ ___ | ||||
| * [Usage](#usage) | ||||
|   * [Git context](#git-context) | ||||
|   * [Path context](#path-context) | ||||
|   * [Isolated builders](#isolated-builders) | ||||
|   * [Multi-platform image](#multi-platform-image) | ||||
| * [Advanced usage](#advanced-usage) | ||||
|   * [Push to multi-registries](#push-to-multi-registries) | ||||
|   * [Cache to registry](#push-to-multi-registries) | ||||
|   * [Local registry](#local-registry) | ||||
|   * [Export image to Docker](#export-image-to-docker) | ||||
|   * [Leverage GitHub cache](#leverage-github-cache) | ||||
|   * [Handle tags and labels](#handle-tags-and-labels) | ||||
|   * [Update DockerHub repo description](#update-dockerhub-repo-description) | ||||
|   * [Multi-platform image](docs/advanced/multi-platform.md) | ||||
|   * [Secrets](docs/advanced/secrets.md) | ||||
|   * [Isolated builders](docs/advanced/isolated-builders.md) | ||||
|   * [Push to multi-registries](docs/advanced/push-multi-registries.md) | ||||
|   * [Cache](docs/advanced/cache.md) | ||||
|     * [Registry cache](docs/advanced/cache.md#registry-cache) | ||||
|     * [GitHub cache](docs/advanced/cache.md#github-cache) | ||||
|   * [Local registry](docs/advanced/local-registry.md) | ||||
|   * [Export image to Docker](docs/advanced/export-docker.md) | ||||
|   * [Handle tags and labels](docs/advanced/tags-labels.md) | ||||
|   * [Update DockerHub repo description](docs/advanced/dockerhub-desc.md) | ||||
| * [Customizing](#customizing) | ||||
|   * [inputs](#inputs) | ||||
|   * [outputs](#outputs) | ||||
| * [Notes](#notes) | ||||
|   * [Multi-line secret value](#multi-line-secret-value) | ||||
| * [Troubleshooting](#troubleshooting) | ||||
| * [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot) | ||||
| * [Limitation](#limitation) | ||||
|  | ||||
| ## Usage | ||||
|  | ||||
| This action uses our [setup-buildx](https://github.com/docker/setup-buildx-action) action that extends the | ||||
| `docker build` command named [buildx](https://github.com/docker/buildx) with the full support of the features | ||||
| 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. | ||||
| By default, this action uses the [Git context](#git-context) so you don't need to use the | ||||
| [`actions/checkout`](https://github.com/actions/checkout/) action to checkout the repository because this will be | ||||
| done directly by buildkit. The git reference will be based on the [event that triggered your workflow](https://docs.github.com/en/actions/reference/events-that-trigger-workflows) | ||||
| and will result in the following context: `https://github.com/<owner>/<repo>.git#<ref>`. | ||||
|  | ||||
| Be careful because **any file mutation in the steps that precede the build step will be ignored** since | ||||
| the context is based on the git reference. However, you can use the [Path context](#path-context) using the | ||||
| [`context` input](#inputs) alongside the [`actions/checkout`](https://github.com/actions/checkout/) action to remove | ||||
| this restriction. | ||||
|  | ||||
| In the examples below we are using 3 other actions: | ||||
|  | ||||
| * [`setup-buildx`](https://github.com/docker/setup-buildx-action) action will create and boot a builder using by  | ||||
| default the `docker-container` [builder driver](https://github.com/docker/buildx/blob/master/docs/reference/buildx_create.md#driver). | ||||
| This is **not required but recommended** using it to be able to build multi-platform images, export cache, etc. | ||||
| * [`setup-qemu`](https://github.com/docker/setup-qemu-action) action can be useful if you want | ||||
| to add emulation support with QEMU to be able to build against more platforms.  | ||||
| * [`login`](https://github.com/docker/login-action) action will take care to log in against a Docker registry. | ||||
|  | ||||
| ### Git context | ||||
|  | ||||
| The default behavior of this action is to use the Git context invoked by your workflow. | ||||
| (eg. `https://github.com/<owner>/<repo>.git#<ref>`) | ||||
|  | ||||
| ```yaml | ||||
| name: ci | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: master | ||||
|     branches: | ||||
|       - 'master' | ||||
|  | ||||
| jobs: | ||||
|   main: | ||||
|   docker: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
| @@ -92,17 +99,14 @@ jobs: | ||||
|         with: | ||||
|           push: true | ||||
|           tags: user/app:latest | ||||
|           build-args: | | ||||
|             arg1=value1 | ||||
|             arg2=value2 | ||||
|       - | ||||
|         name: Image digest | ||||
|         run: echo ${{ steps.docker_build.outputs.digest }} | ||||
| ``` | ||||
|  | ||||
| Building from current repository automatically uses the [GitHub Token](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token) | ||||
| as provided by `secrets` so it does not need to be passed. But if you want to authenticate against another private | ||||
| repository, you have to use a secret named `GIT_AUTH_TOKEN` to be able to authenticate against it with buildx: | ||||
| Building from the current repository automatically uses the [GitHub Token](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token) | ||||
| so it does not need to be passed. If you want to authenticate against another private repository, you have to use | ||||
| a [secret](docs/advanced/secrets.md) named `GIT_AUTH_TOKEN` to be able to authenticate against it with buildx: | ||||
|  | ||||
| ```yaml | ||||
|       - | ||||
| @@ -117,23 +121,20 @@ repository, you have to use a secret named `GIT_AUTH_TOKEN` to be able to authen | ||||
| ``` | ||||
|  | ||||
| > :warning: Subdir for Git context is not yet supported ([moby/buildkit#1684](https://github.com/moby/buildkit/issues/1684)) | ||||
| > but you can use the [path context](#path-context) in the meantime. | ||||
|  | ||||
| > More info: https://docs.docker.com/engine/reference/commandline/build/#git-repositories | ||||
| > but you can use the [path context](#path-context) in the meantime. More info on [Docker docs website](https://docs.docker.com/engine/reference/commandline/build/#git-repositories). | ||||
|  | ||||
| ### 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 | ||||
|     branches: | ||||
|       - 'master' | ||||
|  | ||||
| jobs: | ||||
|   path-context: | ||||
|   docker: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
| @@ -156,435 +157,23 @@ jobs: | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           context: . | ||||
|           file: ./Dockerfile | ||||
|           platforms: linux/amd64,linux/arm64,linux/386 | ||||
|           push: true | ||||
|           tags: user/app:latest | ||||
| ``` | ||||
|  | ||||
| ### Isolated builders | ||||
|  | ||||
| ```yaml | ||||
| name: ci | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: master | ||||
|  | ||||
| jobs: | ||||
|   multi-builders: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|         id: builder1 | ||||
|       - | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|         id: builder2 | ||||
|       - | ||||
|         name: Builder 1 name | ||||
|         run: echo ${{ steps.builder1.outputs.name }} | ||||
|       - | ||||
|         name: Builder 2 name | ||||
|         run: echo ${{ steps.builder2.outputs.name }} | ||||
|       - | ||||
|         name: Build against builder1 | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           builder: ${{ steps.builder1.outputs.name }} | ||||
|           target: mytarget1 | ||||
|       - | ||||
|         name: Build against builder2 | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           builder: ${{ steps.builder2.outputs.name }} | ||||
|           target: mytarget2 | ||||
| ``` | ||||
|  | ||||
| ### Multi-platform image | ||||
|  | ||||
| ```yaml | ||||
| name: ci | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: master | ||||
|  | ||||
| jobs: | ||||
|   multi: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@v1 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|       - | ||||
|         name: Login to DockerHub | ||||
|         uses: docker/login-action@v1  | ||||
|         with: | ||||
|           username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|           password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
|       - | ||||
|         name: Build and push | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           context: . | ||||
|           file: ./Dockerfile | ||||
|           platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x | ||||
|           push: true | ||||
|           tags: | | ||||
|             user/app:latest | ||||
|             user/app:1.0.0 | ||||
| ``` | ||||
|  | ||||
| ## Advanced usage | ||||
|  | ||||
| ### Push to multi-registries | ||||
|  | ||||
| The following workflow will connect you to [DockerHub](https://github.com/docker/login-action#dockerhub) | ||||
| and [GitHub Container Registry](https://github.com/docker/login-action#github-container-registry) and push the | ||||
| image to these registries. | ||||
|  | ||||
| <details> | ||||
|   <summary><b>Show workflow</b></summary> | ||||
|    | ||||
|   ```yaml | ||||
|   name: ci | ||||
|    | ||||
|   on: | ||||
|     push: | ||||
|       branches: master | ||||
|    | ||||
|   jobs: | ||||
|     multi-registries: | ||||
|       runs-on: ubuntu-latest | ||||
|       steps: | ||||
|         - | ||||
|           name: Checkout | ||||
|           uses: actions/checkout@v2 | ||||
|         - | ||||
|           name: Set up QEMU | ||||
|           uses: docker/setup-qemu-action@v1 | ||||
|         - | ||||
|           name: Set up Docker Buildx | ||||
|           uses: docker/setup-buildx-action@v1 | ||||
|         - | ||||
|           name: Login to DockerHub | ||||
|           uses: docker/login-action@v1  | ||||
|           with: | ||||
|             username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|             password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
|         - | ||||
|           name: Login to GitHub Container Registry | ||||
|           uses: docker/login-action@v1  | ||||
|           with: | ||||
|             registry: ghcr.io | ||||
|             username: ${{ github.repository_owner }} | ||||
|             password: ${{ secrets.CR_PAT }} | ||||
|         - | ||||
|           name: Build and push | ||||
|           uses: docker/build-push-action@v2 | ||||
|           with: | ||||
|             context: . | ||||
|             file: ./Dockerfile | ||||
|             platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x | ||||
|             push: true | ||||
|             tags: | | ||||
|               user/app:latest | ||||
|               user/app:1.0.0 | ||||
|               ghcr.io/user/app:latest | ||||
|               ghcr.io/user/app:1.0.0 | ||||
|   ``` | ||||
| </details> | ||||
|  | ||||
| ### Cache to registry | ||||
|  | ||||
| You can import/export cache from a cache manifest or (special) image configuration on the registry. | ||||
|  | ||||
| <details> | ||||
|   <summary><b>Show workflow</b></summary> | ||||
|    | ||||
|   ```yaml | ||||
|   name: ci | ||||
|  | ||||
|   on: | ||||
|     push: | ||||
|       branches: master | ||||
|  | ||||
|   jobs: | ||||
|     registry-cache: | ||||
|       runs-on: ubuntu-latest | ||||
|       steps: | ||||
|         - | ||||
|           name: Set up Docker Buildx | ||||
|           uses: docker/setup-buildx-action@v1 | ||||
|         - | ||||
|           name: Login to DockerHub | ||||
|           uses: docker/login-action@v1  | ||||
|           with: | ||||
|             username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|             password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
|         - | ||||
|           name: Build and push | ||||
|           uses: docker/build-push-action@v2 | ||||
|           with: | ||||
|             push: true | ||||
|             tags: user/app:latest | ||||
|             cache-from: type=registry,ref=user/app:latest | ||||
|             cache-to: type=inline | ||||
|   ``` | ||||
| </details> | ||||
|  | ||||
| ### Local registry | ||||
|  | ||||
| For testing purposes you may need to create a [local registry](https://hub.docker.com/_/registry) to push images into: | ||||
|  | ||||
| <details> | ||||
|   <summary><b>Show workflow</b></summary> | ||||
|    | ||||
|   ```yaml | ||||
|   name: ci | ||||
|  | ||||
|   on: | ||||
|     push: | ||||
|       branches: master | ||||
|  | ||||
|   jobs: | ||||
|     local-registry: | ||||
|       runs-on: ubuntu-latest | ||||
|       services: | ||||
|         registry: | ||||
|           image: registry:2 | ||||
|           ports: | ||||
|             - 5000:5000 | ||||
|       steps: | ||||
|         - | ||||
|           name: Set up QEMU | ||||
|           uses: docker/setup-qemu-action@v1 | ||||
|         - | ||||
|           name: Set up Docker Buildx | ||||
|           uses: docker/setup-buildx-action@v1 | ||||
|           with: | ||||
|             driver-opts: network=host | ||||
|         - | ||||
|           name: Build and push to local registry | ||||
|           uses: docker/build-push-action@v2 | ||||
|           with: | ||||
|             push: true | ||||
|             tags: localhost:5000/name/app:latest | ||||
|         - | ||||
|           name: Inspect | ||||
|           run: | | ||||
|             docker buildx imagetools inspect localhost:5000/name/app:latest | ||||
|   ``` | ||||
| </details> | ||||
|  | ||||
| ### Export image to Docker | ||||
|  | ||||
| You may want your build result to be available in the Docker client through `docker images` to be able to use it | ||||
| in another step of your workflow: | ||||
|  | ||||
| <details> | ||||
|   <summary><b>Show workflow</b></summary> | ||||
|    | ||||
|   ```yaml | ||||
|   name: ci | ||||
|  | ||||
|   on: | ||||
|     push: | ||||
|       branches: master | ||||
|  | ||||
|   jobs: | ||||
|     export-docker: | ||||
|       runs-on: ubuntu-latest | ||||
|       steps: | ||||
|         - | ||||
|           name: Checkout | ||||
|           uses: actions/checkout@v2 | ||||
|         - | ||||
|           name: Set up Docker Buildx | ||||
|           uses: docker/setup-buildx-action@v1 | ||||
|         - | ||||
|           name: Build | ||||
|           uses: docker/build-push-action@v2 | ||||
|           with: | ||||
|             context: . | ||||
|             file: ./Dockerfile | ||||
|             load: true | ||||
|             tags: myimage:latest | ||||
|         - | ||||
|           name: Inspect | ||||
|           run: | | ||||
|             docker image inspect myimage:latest | ||||
|   ``` | ||||
| </details> | ||||
|  | ||||
| ### Leverage GitHub cache | ||||
|  | ||||
| You can leverage [GitHub cache](https://docs.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows) | ||||
| using [actions/cache](https://github.com/actions/cache) with this action: | ||||
|  | ||||
| <details> | ||||
|   <summary><b>Show workflow</b></summary> | ||||
|    | ||||
|   ```yaml | ||||
|   name: ci | ||||
|  | ||||
|   on: | ||||
|     push: | ||||
|       branches: master | ||||
|  | ||||
|   jobs: | ||||
|     github-cache: | ||||
|       runs-on: ubuntu-latest | ||||
|       steps: | ||||
|         - | ||||
|           name: Set up Docker Buildx | ||||
|           uses: docker/setup-buildx-action@v1 | ||||
|         - | ||||
|           name: Cache Docker layers | ||||
|           uses: actions/cache@v2 | ||||
|           with: | ||||
|             path: /tmp/.buildx-cache | ||||
|             key: ${{ runner.os }}-buildx-${{ github.sha }} | ||||
|             restore-keys: | | ||||
|               ${{ runner.os }}-buildx- | ||||
|         - | ||||
|           name: Login to DockerHub | ||||
|           uses: docker/login-action@v1  | ||||
|           with: | ||||
|             username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|             password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
|         - | ||||
|           name: Build and push | ||||
|           uses: docker/build-push-action@v2 | ||||
|           with: | ||||
|             push: true | ||||
|             tags: user/app:latest | ||||
|             cache-from: type=local,src=/tmp/.buildx-cache | ||||
|             cache-to: type=local,dest=/tmp/.buildx-cache | ||||
|   ``` | ||||
| </details> | ||||
|  | ||||
| > If you want to [export layers for all stages](https://github.com/docker/buildx#--cache-tonametypetypekeyvalue), | ||||
| > you have to specify `mode=max` attribute in `cache-to`. | ||||
|  | ||||
| ### Handle tags and labels | ||||
|  | ||||
| If you come from [`v1`](https://github.com/docker/build-push-action/tree/releases/v1#readme) and want an | ||||
| "automatic" tag management and [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md) | ||||
| for labels, you can do it in a dedicated step. The following workflow will use the [Docker meta action](https://github.com/crazy-max/ghaction-docker-meta) | ||||
| to handle tags and labels based on GitHub actions events and Git metadata. | ||||
|  | ||||
| <details> | ||||
|   <summary><b>Show workflow</b></summary> | ||||
|    | ||||
|   ```yaml | ||||
|   name: ci | ||||
|  | ||||
|   on: | ||||
|     schedule: | ||||
|       - cron: '0 10 * * *' # everyday at 10am | ||||
|     push: | ||||
|       branches: | ||||
|         - '**' | ||||
|       tags: | ||||
|         - 'v*.*.*' | ||||
|     pull_request: | ||||
|  | ||||
|   jobs: | ||||
|     docker: | ||||
|       runs-on: ubuntu-latest | ||||
|       steps: | ||||
|         - | ||||
|           name: Checkout | ||||
|           uses: actions/checkout@v2 | ||||
|         - | ||||
|           name: Docker meta | ||||
|           id: docker_meta | ||||
|           uses: crazy-max/ghaction-docker-meta@v1 | ||||
|           with: | ||||
|             images: name/app # list of Docker images to use as base name for tags | ||||
|             tag-sha: true # add git short SHA as Docker tag | ||||
|         - | ||||
|           name: Set up QEMU | ||||
|           uses: docker/setup-qemu-action@v1 | ||||
|         - | ||||
|           name: Set up Docker Buildx | ||||
|           uses: docker/setup-buildx-action@v1 | ||||
|         - | ||||
|           name: Login to DockerHub | ||||
|           if: github.event_name != 'pull_request' | ||||
|           uses: docker/login-action@v1  | ||||
|           with: | ||||
|             username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|             password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
|         - | ||||
|           name: Build and push | ||||
|           id: docker_build | ||||
|           uses: docker/build-push-action@v2 | ||||
|           with: | ||||
|             context: . | ||||
|             file: ./Dockerfile | ||||
|             platforms: linux/amd64,linux/arm64,linux/386 | ||||
|             push: ${{ github.event_name != 'pull_request' }} | ||||
|             tags: ${{ steps.docker_meta.outputs.tags }} | ||||
|             labels: ${{ steps.docker_meta.outputs.labels }} | ||||
|   ``` | ||||
| </details> | ||||
|  | ||||
| ### Update DockerHub repo description | ||||
|  | ||||
| You can update the [DockerHub repository description](https://docs.docker.com/docker-hub/repos/) using | ||||
| a third-party action called [DockerHub Description](https://github.com/peter-evans/dockerhub-description) | ||||
| with this action: | ||||
|  | ||||
| <details> | ||||
|   <summary><b>Show workflow</b></summary> | ||||
|    | ||||
|   ```yaml | ||||
|   name: ci | ||||
|  | ||||
|   on: | ||||
|     push: | ||||
|       branches: master | ||||
|  | ||||
|   jobs: | ||||
|     main: | ||||
|       runs-on: ubuntu-latest | ||||
|       steps: | ||||
|         - | ||||
|           name: Set up QEMU | ||||
|           uses: docker/setup-qemu-action@v1 | ||||
|         - | ||||
|           name: Set up Docker Buildx | ||||
|           uses: docker/setup-buildx-action@v1 | ||||
|         - | ||||
|           name: Login to DockerHub | ||||
|           uses: docker/login-action@v1  | ||||
|           with: | ||||
|             username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|             password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
|         - | ||||
|           name: Build and push | ||||
|           uses: docker/build-push-action@v2 | ||||
|           with: | ||||
|             push: true | ||||
|             tags: user/app:latest | ||||
|         - | ||||
|           name: Update repo description | ||||
|           uses: peter-evans/dockerhub-description@v2 | ||||
|           with: | ||||
|             username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|             password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||||
|             repository: user/app | ||||
|   ``` | ||||
| </details> | ||||
| * [Multi-platform image](docs/advanced/multi-platform.md) | ||||
| * [Secrets](docs/advanced/secrets.md) | ||||
| * [Isolated builders](docs/advanced/isolated-builders.md) | ||||
| * [Push to multi-registries](docs/advanced/push-multi-registries.md) | ||||
| * [Cache](docs/advanced/cache.md) | ||||
|   * [Registry cache](docs/advanced/cache.md#registry-cache) | ||||
|   * [GitHub cache](docs/advanced/cache.md#github-cache) | ||||
| * [Local registry](docs/advanced/local-registry.md) | ||||
| * [Export image to Docker](docs/advanced/export-docker.md) | ||||
| * [Handle tags and labels](docs/advanced/tags-labels.md) | ||||
| * [Update DockerHub repo description](docs/advanced/dockerhub-desc.md) | ||||
|  | ||||
| ## Customizing | ||||
|  | ||||
| @@ -606,24 +195,26 @@ Following inputs can be used as `step.with` keys | ||||
|  | ||||
| | Name                | Type     | Description                        | | ||||
| |---------------------|----------|------------------------------------| | ||||
| | `allow`             | List/CSV | List of [extra privileged entitlement](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#allow) (eg. `network.host,security.insecure`) | | ||||
| | `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 [Git context](#git-context)) | | ||||
| | `file`              | String   | Path to the Dockerfile (default `./Dockerfile`) | | ||||
| | `build-args`        | List     | List of build-time variables | | ||||
| | `cache-from`        | List     | List of [external cache sources](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#cache-from) (eg. `type=local,src=path/to/dir`) | | ||||
| | `cache-to`          | List     | List of [cache export destinations](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#cache-to) (eg. `type=local,dest=path/to/dir`) | | ||||
| | `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 `{context}/Dockerfile`) | | ||||
| | `labels`            | List     | List of metadata for an image | | ||||
| | `tags`              | List/CSV | List of tags | | ||||
| | `pull`              | Bool     | Always attempt to pull a newer version of the image (default `false`) | | ||||
| | `target`            | String   | Sets the target stage to build | | ||||
| | `allow`             | List/CSV | List of [extra privileged entitlement](https://github.com/docker/buildx#--allowentitlement) (eg. `network.host,security.insecure`) | | ||||
| | `load`              | Bool     | [Load](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#load) is a shorthand for `--output=type=docker` (default `false`) | | ||||
| | `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`) | | ||||
| | `platforms`         | List/CSV | List of [target platforms](https://github.com/docker/buildx#---platformvaluevalue) for build | | ||||
| | `load`              | Bool     | [Load](https://github.com/docker/buildx#--load) is a shorthand for `--output=type=docker` (default `false`) | | ||||
| | `push`              | Bool     | [Push](https://github.com/docker/buildx#--push) is a shorthand for `--output=type=registry` (default `false`) | | ||||
| | `outputs`           | List     | List of [output destinations](https://github.com/docker/buildx#-o---outputpath-typetypekeyvalue) (format: `type=local,dest=path`) | | ||||
| | `cache-from`        | List     | List of [external cache sources](https://github.com/docker/buildx#--cache-fromnametypetypekeyvalue) (eg. `type=local,src=path/to/dir`) | | ||||
| | `cache-to`          | List     | List of [cache export destinations](https://github.com/docker/buildx#--cache-tonametypetypekeyvalue) (eg. `type=local,dest=path/to/dir`) | | ||||
| | `secrets`           | List     | List of secrets to expose to the build (eg. `key=value`, `GIT_AUTH_TOKEN=mytoken`) | | ||||
| | `outputs`           | List     | List of [output destinations](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#output) (format: `type=local,dest=path`) | | ||||
| | `platforms`         | List/CSV | List of [target platforms](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#platform) for build | | ||||
| | `pull`              | Bool     | Always attempt to pull a newer version of the image (default `false`) | | ||||
| | `push`              | Bool     | [Push](https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#push) is a shorthand for `--output=type=registry` (default `false`) | | ||||
| | `secrets`           | List     | List of secrets to expose to the build (eg. `key=string`, `GIT_AUTH_TOKEN=mytoken`) | | ||||
| | `secret-files`      | List     | List of secret files to expose to the build (eg. `key=filename`, `MY_SECRET=./secret.txt`) | | ||||
| | `ssh`               | List     | List of SSH agent socket or keys to expose to the build | | ||||
| | `tags`              | List/CSV | List of tags | | ||||
| | `target`            | String   | Sets the target stage to build | | ||||
|  | ||||
| ### outputs | ||||
|  | ||||
| @@ -633,38 +224,6 @@ Following outputs are available | ||||
| |---------------|---------|---------------------------------------| | ||||
| | `digest`      | String  | Image content-addressable identifier also called a digest | | ||||
|  | ||||
| ## Notes | ||||
|  | ||||
| ### Multi-line secret value | ||||
|  | ||||
| To handle multi-line value for a secret, you will need to place the key-value pair between quotes: | ||||
|  | ||||
| ```yaml | ||||
| secrets: | | ||||
|   "MYSECRET=${{ secrets.GPG_KEY }}" | ||||
|   GIT_AUTH_TOKEN=abcdefghi,jklmno=0123456789 | ||||
|   "MYSECRET=aaaaaaaa | ||||
|   bbbbbbb | ||||
|   ccccccccc" | ||||
|   FOO=bar | ||||
|   "EMPTYLINE=aaaa | ||||
|    | ||||
|   bbbb | ||||
|   ccc" | ||||
|   "JSON_SECRET={""key1"":""value1"",""key2"":""value2""}" | ||||
| ``` | ||||
|  | ||||
| | Key                | Value                                            | | ||||
| |--------------------|--------------------------------------------------| | ||||
| | `MYSECRET`         | `***********************` | | ||||
| | `GIT_AUTH_TOKEN`   | `abcdefghi,jklmno=0123456789` | | ||||
| | `MYSECRET`         | `aaaaaaaa\nbbbbbbb\nccccccccc` | | ||||
| | `FOO`              | `bar` | | ||||
| | `EMPTYLINE`        | `aaaa\n\nbbbb\nccc` | | ||||
| | `JSON_SECRET`      | `{"key1":"value1","key2":"value2"}` | | ||||
|  | ||||
| > Note: all quote signs need to be doubled for escaping. | ||||
|  | ||||
| ## Troubleshooting | ||||
|  | ||||
| See [TROUBLESHOOTING.md](TROUBLESHOOTING.md) | ||||
|   | ||||
| @@ -1,113 +1,7 @@ | ||||
| # Troubleshooting | ||||
|  | ||||
| * [`auto-push is currently not implemented for docker driver`](#auto-push-is-currently-not-implemented-for-docker-driver) | ||||
| * [Cannot push to a registry](#cannot-push-to-a-registry) | ||||
|  | ||||
| ## `auto-push is currently not implemented for docker driver` | ||||
|  | ||||
| If you're using the default builder (which uses the docker driver) without using our `setup-buildx-action`, you may | ||||
| encounter this error message if you try to push your image: | ||||
|  | ||||
| ``` | ||||
| Run docker/build-push-action@v2 | ||||
| 📣 Buildx version: 0.4.2 | ||||
| 🏃 Starting build... | ||||
| /usr/bin/docker buildx build --tag localhost:5000/name/app:latest --iidfile /tmp/docker-build-push-eYl8PB/iidfile --file ./test/Dockerfile --push ./test | ||||
| auto-push is currently not implemented for docker driver | ||||
| Error: buildx call failed with: auto-push is currently not implemented for docker driver | ||||
| ``` | ||||
|  | ||||
| While waiting for an implementation to be done on buildx/buildkit, you have the following possibilities | ||||
| to solve this atm: | ||||
|  | ||||
| ### With `docker-container` driver and `setup-buildx` | ||||
|  | ||||
| > Recommended solution | ||||
|  | ||||
| ```yaml | ||||
| jobs: | ||||
|   build: | ||||
|     - | ||||
|       name: Checkout | ||||
|       uses: actions/checkout@v2 | ||||
|     - | ||||
|       name: Set up Docker Buildx | ||||
|       uses: docker/setup-buildx-action@v1 | ||||
|     - | ||||
|       name: Login | ||||
|       uses: docker/login-action@v1 | ||||
|       with: | ||||
|         registry: ${{ env.REGISTRY }} | ||||
|         username: ${{ env.USER }} | ||||
|         password: ${{ secrets.PASSWORD }} | ||||
|     - | ||||
|       name: Build and push | ||||
|       uses: docker/build-push-action@v2 | ||||
|       with: | ||||
|         context: . | ||||
|         tags: ${{ env.REGISTRY }}/myapp:latest | ||||
|         push: true | ||||
| ``` | ||||
|  | ||||
| ### With `docker` driver | ||||
|  | ||||
| ```yaml | ||||
| jobs: | ||||
|   build: | ||||
|     - | ||||
|       name: Checkout | ||||
|       uses: actions/checkout@v2 | ||||
|     - | ||||
|       name: Login | ||||
|       uses: docker/login-action@v1 | ||||
|       with: | ||||
|         registry: ${{ env.REGISTRY }} | ||||
|         username: ${{ env.USER }} | ||||
|         password: ${{ secrets.PASSWORD }} | ||||
|     - | ||||
|       name: Build | ||||
|       uses: docker/build-push-action@v2 | ||||
|       with: | ||||
|         context: . | ||||
|         tags: ${{ env.REGISTRY }}/myapp:latest | ||||
|         load: true | ||||
|     - | ||||
|       name: Push | ||||
|       run: docker push ${{ env.REGISTRY }}/myapp:latest | ||||
| ``` | ||||
|  | ||||
| ### With `docker` driver and `setup-buildx` | ||||
|  | ||||
| ```yaml | ||||
| jobs: | ||||
|   build: | ||||
|     - | ||||
|       name: Checkout | ||||
|       uses: actions/checkout@v2 | ||||
|     - | ||||
|       name: Set up Docker Buildx | ||||
|       uses: docker/setup-buildx-action@v1 | ||||
|       with: | ||||
|         driver: docker | ||||
|     - | ||||
|       name: Login | ||||
|       uses: docker/login-action@v1 | ||||
|       with: | ||||
|         registry: ${{ env.REGISTRY }} | ||||
|         username: ${{ env.USER }} | ||||
|         password: ${{ secrets.PASSWORD }} | ||||
|     - | ||||
|       name: Build | ||||
|       uses: docker/build-push-action@v2 | ||||
|       with: | ||||
|         context: . | ||||
|         tags: ${{ env.REGISTRY }}/myapp:latest | ||||
|         load: true | ||||
|     - | ||||
|       name: Push | ||||
|       run: docker push ${{ env.REGISTRY }}/myapp:latest | ||||
| ``` | ||||
|  | ||||
| ## Cannot push to a registry | ||||
|  | ||||
| While pushing to a registry, you may encounter these kinds of issues: | ||||
| @@ -165,8 +59,7 @@ jobs: | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           context: . | ||||
|           file: ./Dockerfile | ||||
|           platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x | ||||
|           platforms: linux/amd64,linux/arm64 | ||||
|           tags: docker.io/user/app:latest | ||||
|           outputs: type=oci,dest=/tmp/image.tar | ||||
|       - | ||||
|   | ||||
							
								
								
									
										18
									
								
								UPGRADE.md
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								UPGRADE.md
									
									
									
									
									
								
							| @@ -7,12 +7,12 @@ | ||||
| * Rename `dockerfile` input to `file` for consistency with other Docker build tools | ||||
| * Rename `always_pull` input to `pull` for consistency with other Docker build tools | ||||
| * Add `builder` input to be able to choose a builder instance through our [setup-buildx action](https://github.com/docker/setup-buildx-action) | ||||
| * Add [`platforms`](https://github.com/docker/buildx#---platformvaluevalue) input to support multi-platform builds | ||||
| * Add [`allow`](https://github.com/docker/buildx#--allowentitlement) input | ||||
| * Add [`load`](https://github.com/docker/buildx#--load) input | ||||
| * Add [`outputs`](https://github.com/docker/buildx#-o---outputpath-typetypekeyvalue) input | ||||
| * Add [`cache-from`](https://github.com/docker/buildx#--cache-fromnametypetypekeyvalue) input (`cache_froms` removed) | ||||
| * Add [`cache-to`](https://github.com/docker/buildx#--cache-tonametypetypekeyvalue) input | ||||
| * Add `platforms` input to support multi-platform builds | ||||
| * Add `allow` input | ||||
| * Add `load` input | ||||
| * Add `outputs` input | ||||
| * Add `cache-from` input (`cache_froms` removed) | ||||
| * Add `cache-to` input | ||||
| * Rename `build_args` input to `build-args` for consistency with other Docker build tools | ||||
| * Add `secrets` input | ||||
| * Review `tags` input | ||||
| @@ -63,7 +63,6 @@ steps: | ||||
|     uses: docker/build-push-action@v2 | ||||
|     with: | ||||
|       context: . | ||||
|       file: ./Dockerfile | ||||
|       pull: true | ||||
|       push: true | ||||
|       build-args: | | ||||
| @@ -136,7 +135,6 @@ steps: | ||||
|     uses: docker/build-push-action@v2 | ||||
|     with: | ||||
|       context: . | ||||
|       file: ./Dockerfile | ||||
|       push: ${{ github.event_name != 'pull_request' }} | ||||
|       tags: ${{ steps.prep.outputs.tags }} | ||||
|       labels: | | ||||
| @@ -145,5 +143,5 @@ steps: | ||||
|         org.opencontainers.image.revision=${{ github.sha }} | ||||
| ``` | ||||
|  | ||||
| > You can also use the [Docker meta action](https://github.com/crazy-max/ghaction-docker-meta) to handle tags and | ||||
| > labels based on GitHub actions events and Git metadata. A workflow example is available in the [README](README.md#handle-tags-and-labels). | ||||
| > You can also use the [Docker meta action to handle tags and labels](docs/advanced/tags-labels.md) based on GitHub | ||||
| > actions events and Git metadata. | ||||
|   | ||||
| @@ -119,21 +119,34 @@ describe('parseVersion', () => { | ||||
|  | ||||
| describe('getSecret', () => { | ||||
|   test.each([ | ||||
|     ['A_SECRET=abcdef0123456789', 'A_SECRET', 'abcdef0123456789', false], | ||||
|     ['GIT_AUTH_TOKEN=abcdefghijklmno=0123456789', 'GIT_AUTH_TOKEN', 'abcdefghijklmno=0123456789', false], | ||||
|     ['MY_KEY=c3RyaW5nLXdpdGgtZXF1YWxzCg==', 'MY_KEY', 'c3RyaW5nLXdpdGgtZXF1YWxzCg==', false], | ||||
|     ['aaaaaaaa', '', '', true], | ||||
|     ['aaaaaaaa=', '', '', true], | ||||
|     ['=bbbbbbb', '', '', true] | ||||
|   ])('given %p key and %p secret', async (kvp, key, secret, invalid) => { | ||||
|     ['A_SECRET=abcdef0123456789', false, 'A_SECRET', 'abcdef0123456789', false], | ||||
|     ['GIT_AUTH_TOKEN=abcdefghijklmno=0123456789', false, 'GIT_AUTH_TOKEN', 'abcdefghijklmno=0123456789', false], | ||||
|     ['MY_KEY=c3RyaW5nLXdpdGgtZXF1YWxzCg==', false, 'MY_KEY', 'c3RyaW5nLXdpdGgtZXF1YWxzCg==', false], | ||||
|     ['aaaaaaaa', false, '', '', true], | ||||
|     ['aaaaaaaa=', false, '', '', true], | ||||
|     ['=bbbbbbb', false, '', '', true], | ||||
|     [ | ||||
|       `foo=${path.join(__dirname, 'fixtures', 'secret.txt').split(path.sep).join(path.posix.sep)}`, | ||||
|       true, | ||||
|       'foo', | ||||
|       'bar', | ||||
|       false | ||||
|     ], | ||||
|     [`notfound=secret`, true, '', '', true] | ||||
|   ])('given %p key and %p secret', async (kvp, file, exKey, exValue, invalid) => { | ||||
|     try { | ||||
|       const secretArgs = await buildx.getSecret(kvp); | ||||
|       let secret: string; | ||||
|       if (file) { | ||||
|         secret = await buildx.getSecretFile(kvp); | ||||
|       } else { | ||||
|         secret = await buildx.getSecretString(kvp); | ||||
|       } | ||||
|       expect(true).toBe(!invalid); | ||||
|       console.log(`secretArgs: ${secretArgs}`); | ||||
|       expect(secretArgs).toEqual(`id=${key},src=${tmpNameSync}`); | ||||
|       const secretContent = await fs.readFileSync(tmpNameSync, 'utf-8'); | ||||
|       console.log(`secretValue: ${secretContent}`); | ||||
|       expect(secretContent).toEqual(secret); | ||||
|       console.log(`secret: ${secret}`); | ||||
|       expect(secret).toEqual(`id=${exKey},src=${tmpNameSync}`); | ||||
|       const secretValue = await fs.readFileSync(tmpNameSync, 'utf-8'); | ||||
|       console.log(`secretValue: ${secretValue}`); | ||||
|       expect(secretValue).toEqual(exValue); | ||||
|     } catch (err) { | ||||
|       expect(true).toBe(invalid); | ||||
|     } | ||||
|   | ||||
| @@ -147,7 +147,6 @@ describe('getArgs', () => { | ||||
|         'buildx', | ||||
|         'build', | ||||
|         '--iidfile', '/tmp/.docker-build-push-jest/iidfile', | ||||
|         '--file', 'Dockerfile', | ||||
|         '.' | ||||
|       ] | ||||
|     ], | ||||
| @@ -162,7 +161,6 @@ describe('getArgs', () => { | ||||
|         '--build-arg', 'MY_ARG=val1,val2,val3', | ||||
|         '--build-arg', 'ARG=val', | ||||
|         '--iidfile', '/tmp/.docker-build-push-jest/iidfile', | ||||
|         '--file', 'Dockerfile', | ||||
|         'https://github.com/docker/build-push-action.git#test-jest' | ||||
|       ] | ||||
|     ], | ||||
| @@ -177,7 +175,6 @@ describe('getArgs', () => { | ||||
|         '--tag', 'name/app:7.4', | ||||
|         '--tag', 'name/app:latest', | ||||
|         '--iidfile', '/tmp/.docker-build-push-jest/iidfile', | ||||
|         '--file', 'Dockerfile', | ||||
|         'https://github.com/docker/build-push-action.git#test-jest' | ||||
|       ] | ||||
|     ], | ||||
| @@ -194,7 +191,6 @@ describe('getArgs', () => { | ||||
|         '--label', 'org.opencontainers.image.title=buildkit', | ||||
|         '--label', 'org.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit', | ||||
|         '--output', 'type=local,dest=./release-out', | ||||
|         '--file', 'Dockerfile', | ||||
|         '.' | ||||
|       ] | ||||
|     ], | ||||
| @@ -208,7 +204,6 @@ describe('getArgs', () => { | ||||
|         'buildx', | ||||
|         'build', | ||||
|         '--platform', 'linux/amd64,linux/arm64', | ||||
|         '--file', 'Dockerfile', | ||||
|         '.' | ||||
|       ] | ||||
|     ], | ||||
| @@ -221,7 +216,6 @@ describe('getArgs', () => { | ||||
|         'buildx', | ||||
|         'build', | ||||
|         '--iidfile', '/tmp/.docker-build-push-jest/iidfile', | ||||
|         '--file', 'Dockerfile', | ||||
|         '.' | ||||
|       ] | ||||
|     ], | ||||
| @@ -236,7 +230,6 @@ describe('getArgs', () => { | ||||
|         'build', | ||||
|         '--iidfile', '/tmp/.docker-build-push-jest/iidfile', | ||||
|         '--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest', | ||||
|         '--file', 'Dockerfile', | ||||
|         '.' | ||||
|       ] | ||||
|     ], | ||||
| @@ -251,7 +244,6 @@ describe('getArgs', () => { | ||||
|         'build', | ||||
|         '--output', '.', | ||||
|         '--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest', | ||||
|         '--file', 'Dockerfile', | ||||
|         'https://github.com/docker/build-push-action.git#test-jest' | ||||
|       ] | ||||
|     ], | ||||
| @@ -345,6 +337,29 @@ ccc`], | ||||
|         '--push', | ||||
|         'https://github.com/docker/build-push-action.git#heads/master' | ||||
|       ] | ||||
|     ], | ||||
|     [ | ||||
|       '0.5.1', | ||||
|       new Map<string, string>([ | ||||
|         ['context', 'https://github.com/docker/build-push-action.git#heads/master'], | ||||
|         ['tag', 'localhost:5000/name/app:latest'], | ||||
|         ['secret-files', `MY_SECRET=${path.join(__dirname, 'fixtures', 'secret.txt').split(path.sep).join(path.posix.sep)}`], | ||||
|         ['file', './test/Dockerfile'], | ||||
|         ['builder', 'builder-git-context-2'], | ||||
|         ['network', 'host'], | ||||
|         ['push', 'true'] | ||||
|       ]), | ||||
|       [ | ||||
|         'buildx', | ||||
|         'build', | ||||
|         '--iidfile', '/tmp/.docker-build-push-jest/iidfile', | ||||
|         '--secret', 'id=MY_SECRET,src=/tmp/.docker-build-push-jest/.tmpname-jest', | ||||
|         '--file', './test/Dockerfile', | ||||
|         '--builder', 'builder-git-context-2', | ||||
|         '--network', 'host', | ||||
|         '--push', | ||||
|         'https://github.com/docker/build-push-action.git#heads/master' | ||||
|       ] | ||||
|     ] | ||||
|   ])( | ||||
|     'given %p with %p as inputs, returns %p', | ||||
|   | ||||
							
								
								
									
										1
									
								
								__tests__/fixtures/secret.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								__tests__/fixtures/secret.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| bar | ||||
							
								
								
									
										97
									
								
								action.yml
									
									
									
									
									
								
							
							
						
						
									
										97
									
								
								action.yml
									
									
									
									
									
								
							| @@ -7,52 +7,14 @@ branding: | ||||
|   color: 'blue' | ||||
|  | ||||
| inputs: | ||||
|   builder: | ||||
|     description: "Builder instance" | ||||
|     required: false | ||||
|   context: | ||||
|     description: "Build's context is the set of files located in the specified PATH or URL" | ||||
|     required: false | ||||
|   file: | ||||
|     description: "Path to the Dockerfile" | ||||
|     required: false | ||||
|     default: './Dockerfile' | ||||
|   build-args: | ||||
|     description: "List of build-time variables" | ||||
|     required: false | ||||
|   labels: | ||||
|     description: "List of metadata for an image" | ||||
|     required: false | ||||
|   tags: | ||||
|     description: "List of tags" | ||||
|     required: false | ||||
|   pull: | ||||
|     description: "Always attempt to pull a newer version of the image" | ||||
|     required: false | ||||
|     default: 'false' | ||||
|   target: | ||||
|     description: "Sets the target stage to build" | ||||
|     required: false | ||||
|   allow: | ||||
|     description: "List of extra privileged entitlement (eg. network.host,security.insecure)" | ||||
|     required: false | ||||
|   no-cache: | ||||
|     description: "Do not use cache when building the image" | ||||
|   build-args: | ||||
|     description: "List of build-time variables" | ||||
|     required: false | ||||
|     default: 'false' | ||||
|   platforms: | ||||
|     description: "List of target platforms for build" | ||||
|     required: false | ||||
|   load: | ||||
|     description: "Load is a shorthand for --output=type=docker" | ||||
|     required: false | ||||
|     default: 'false' | ||||
|   push: | ||||
|     description: "Push is a shorthand for --output=type=registry" | ||||
|     required: false | ||||
|     default: 'false' | ||||
|   outputs: | ||||
|     description: "List of output destinations (format: type=local,dest=path)" | ||||
|   builder: | ||||
|     description: "Builder instance" | ||||
|     required: false | ||||
|   cache-from: | ||||
|     description: "List of external cache sources for buildx (eg. user/app:cache, type=local,src=path/to/dir)" | ||||
| @@ -60,16 +22,59 @@ inputs: | ||||
|   cache-to: | ||||
|     description: "List of cache export destinations for buildx (eg. user/app:cache, type=local,dest=path/to/dir)" | ||||
|     required: false | ||||
|   context: | ||||
|     description: "Build's context is the set of files located in the specified PATH or URL" | ||||
|     required: false | ||||
|   file: | ||||
|     description: "Path to the Dockerfile" | ||||
|     required: false | ||||
|   labels: | ||||
|     description: "List of metadata for an image" | ||||
|     required: false | ||||
|   load: | ||||
|     description: "Load is a shorthand for --output=type=docker" | ||||
|     required: false | ||||
|     default: 'false' | ||||
|   network: | ||||
|     description: "Set the networking mode for the RUN instructions during build" | ||||
|     required: false | ||||
|   no-cache: | ||||
|     description: "Do not use cache when building the image" | ||||
|     required: false | ||||
|     default: 'false' | ||||
|   outputs: | ||||
|     description: "List of output destinations (format: type=local,dest=path)" | ||||
|     required: false | ||||
|   platforms: | ||||
|     description: "List of target platforms for build" | ||||
|     required: false | ||||
|   pull: | ||||
|     description: "Always attempt to pull a newer version of the image" | ||||
|     required: false | ||||
|     default: 'false' | ||||
|   push: | ||||
|     description: "Push is a shorthand for --output=type=registry" | ||||
|     required: false | ||||
|     default: 'false' | ||||
|   secrets: | ||||
|     description: "List of secrets to expose to the build (eg. key=value, GIT_AUTH_TOKEN=mytoken)" | ||||
|     description: "List of secrets to expose to the build (eg. key=string, GIT_AUTH_TOKEN=mytoken)" | ||||
|     required: false | ||||
|   secret-files: | ||||
|     description: "List of secret files to expose to the build (eg. key=filename, MY_SECRET=./secret.txt)" | ||||
|     required: false | ||||
|   ssh: | ||||
|     description: "List of SSH agent socket or keys to expose to the build" | ||||
|     required: false | ||||
|   tags: | ||||
|     description: "List of tags" | ||||
|     required: false | ||||
|   target: | ||||
|     description: "Sets the target stage to build" | ||||
|     required: false | ||||
|   github-token: | ||||
|     description: "GitHub Token used to authenticate against a repository for Git context" | ||||
|     default: ${{ github.token }} | ||||
|     required: false | ||||
|   ssh: | ||||
|     description: "List of SSH agent socket or keys to expose to the build" | ||||
|     required: false | ||||
|  | ||||
| outputs: | ||||
|   digest: | ||||
|   | ||||
							
								
								
									
										291
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										291
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -4581,7 +4581,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| exports.parseVersion = exports.getVersion = exports.isAvailable = exports.hasGitAuthToken = exports.isLocalOrTarExporter = exports.getSecret = exports.getImageID = exports.getImageIDFile = void 0; | ||||
| exports.parseVersion = exports.getVersion = exports.isAvailable = exports.hasGitAuthToken = exports.isLocalOrTarExporter = exports.getSecret = exports.getSecretFile = exports.getSecretString = exports.getImageID = exports.getImageIDFile = void 0; | ||||
| const sync_1 = __importDefault(__webpack_require__(750)); | ||||
| const fs_1 = __importDefault(__webpack_require__(747)); | ||||
| const path_1 = __importDefault(__webpack_require__(622)); | ||||
| @@ -4604,18 +4604,36 @@ function getImageID() { | ||||
|     }); | ||||
| } | ||||
| exports.getImageID = getImageID; | ||||
| function getSecret(kvp) { | ||||
| function getSecretString(kvp) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         return getSecret(kvp, false); | ||||
|     }); | ||||
| } | ||||
| exports.getSecretString = getSecretString; | ||||
| function getSecretFile(kvp) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         return getSecret(kvp, true); | ||||
|     }); | ||||
| } | ||||
| exports.getSecretFile = getSecretFile; | ||||
| function getSecret(kvp, file) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const delimiterIndex = kvp.indexOf('='); | ||||
|         const key = kvp.substring(0, delimiterIndex); | ||||
|         const value = kvp.substring(delimiterIndex + 1); | ||||
|         let value = kvp.substring(delimiterIndex + 1); | ||||
|         if (key.length == 0 || value.length == 0) { | ||||
|             throw new Error(`${kvp} is not a valid secret`); | ||||
|         } | ||||
|         if (file) { | ||||
|             if (!fs_1.default.existsSync(value)) { | ||||
|                 throw new Error(`secret file ${value} not found`); | ||||
|             } | ||||
|             value = fs_1.default.readFileSync(value, { encoding: 'utf-8' }); | ||||
|         } | ||||
|         const secretFile = context.tmpNameSync({ | ||||
|             tmpdir: context.tmpDir() | ||||
|         }); | ||||
|         yield fs_1.default.writeFileSync(secretFile, value); | ||||
|         fs_1.default.writeFileSync(secretFile, value); | ||||
|         return `id=${key},src=${secretFile}`; | ||||
|     }); | ||||
| } | ||||
| @@ -11668,10 +11686,14 @@ additional information. | ||||
| const { Transform } = __webpack_require__(413) | ||||
| const ResizeableBuffer = __webpack_require__(942) | ||||
|  | ||||
| // white space characters | ||||
| // https://en.wikipedia.org/wiki/Whitespace_character | ||||
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes#Types | ||||
| // \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff | ||||
| const tab = 9 | ||||
| const nl = 10 | ||||
| const nl = 10 // \n, 0x0A in hexadecimal, 10 in decimal | ||||
| const np = 12 | ||||
| const cr = 13 | ||||
| const cr = 13 // \r, 0x0D in hexadécimal, 13 in decimal | ||||
| const space = 32 | ||||
| const boms = { | ||||
|   // Note, the following are equals: | ||||
| @@ -11860,6 +11882,27 @@ class Parser extends Transform { | ||||
|         throw new Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(opts.from_line)}`) | ||||
|       } | ||||
|     } | ||||
|     // Normalize options `ignore_last_delimiters` | ||||
|     if(options.ignore_last_delimiters === undefined || options.ignore_last_delimiters === null){ | ||||
|       options.ignore_last_delimiters = false | ||||
|     }else if(typeof options.ignore_last_delimiters === 'number'){ | ||||
|       options.ignore_last_delimiters = Math.floor(options.ignore_last_delimiters) | ||||
|       if(options.ignore_last_delimiters === 0){ | ||||
|         options.ignore_last_delimiters = false | ||||
|       } | ||||
|     }else if(typeof options.ignore_last_delimiters !== 'boolean'){ | ||||
|       throw new CsvError('CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS', [ | ||||
|         'Invalid option `ignore_last_delimiters`:', | ||||
|         'the value must be a boolean value or an integer,', | ||||
|         `got ${JSON.stringify(options.ignore_last_delimiters)}` | ||||
|       ], options) | ||||
|     } | ||||
|     if(options.ignore_last_delimiters === true && options.columns === false){ | ||||
|       throw new CsvError('CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS', [ | ||||
|         'The option `ignore_last_delimiters`', | ||||
|         'requires the activation of the `columns` option' | ||||
|       ], options) | ||||
|     } | ||||
|     // Normalize option `info` | ||||
|     if(options.info === undefined || options.info === null || options.info === false){ | ||||
|       options.info = false | ||||
| @@ -12177,7 +12220,7 @@ class Parser extends Transform { | ||||
|       } | ||||
|       // Auto discovery of record_delimiter, unix, mac and windows supported | ||||
|       if(this.state.quoting === false && record_delimiter.length === 0){ | ||||
|         const record_delimiterCount = this.__autoDiscoverRowDelimiter(buf, pos) | ||||
|         const record_delimiterCount = this.__autoDiscoverRecordDelimiter(buf, pos) | ||||
|         if(record_delimiterCount){ | ||||
|           record_delimiter = this.options.record_delimiter | ||||
|         } | ||||
| @@ -12218,12 +12261,12 @@ class Parser extends Transform { | ||||
|             const isNextChrTrimable = rtrim && this.__isCharTrimable(nextChr) | ||||
|             const isNextChrComment = comment !== null && this.__compareBytes(comment, buf, pos+quote.length, nextChr) | ||||
|             const isNextChrDelimiter = this.__isDelimiter(buf, pos+quote.length, nextChr) | ||||
|             const isNextChrRowDelimiter = record_delimiter.length === 0 ? this.__autoDiscoverRowDelimiter(buf, pos+quote.length) : this.__isRecordDelimiter(nextChr, buf, pos+quote.length) | ||||
|             const isNextChrRecordDelimiter = record_delimiter.length === 0 ? this.__autoDiscoverRecordDelimiter(buf, pos+quote.length) : this.__isRecordDelimiter(nextChr, buf, pos+quote.length) | ||||
|             // Escape a quote | ||||
|             // Treat next char as a regular character | ||||
|             if(escape !== null && this.__isEscape(buf, pos, chr) && this.__isQuote(buf, pos + escape.length)){ | ||||
|               pos += escape.length - 1 | ||||
|             }else if(!nextChr || isNextChrDelimiter || isNextChrRowDelimiter || isNextChrComment || isNextChrTrimable){ | ||||
|             }else if(!nextChr || isNextChrDelimiter || isNextChrRecordDelimiter || isNextChrComment || isNextChrTrimable){ | ||||
|               this.state.quoting = false | ||||
|               this.state.wasQuoting = true | ||||
|               pos += quote.length - 1 | ||||
| @@ -12234,7 +12277,7 @@ class Parser extends Transform { | ||||
|                   'Invalid Closing Quote:', | ||||
|                   `got "${String.fromCharCode(nextChr)}"`, | ||||
|                   `at line ${this.info.lines}`, | ||||
|                   'instead of delimiter, row delimiter, trimable character', | ||||
|                   'instead of delimiter, record delimiter, trimable character', | ||||
|                   '(if activated) or comment', | ||||
|                 ], this.options, this.__context()) | ||||
|               ) | ||||
| @@ -12275,25 +12318,24 @@ class Parser extends Transform { | ||||
|               this.info.comment_lines++ | ||||
|               // Skip full comment line | ||||
|             }else{ | ||||
|               // Activate records emition if above from_line | ||||
|               if(this.state.enabled === false && this.info.lines + (this.state.wasRowDelimiter === true ? 1: 0) >= from_line){ | ||||
|                 this.state.enabled = true | ||||
|                 this.__resetField() | ||||
|                 this.__resetRecord() | ||||
|                 pos += recordDelimiterLength - 1 | ||||
|                 continue | ||||
|               } | ||||
|               // Skip if line is empty and skip_empty_lines activated | ||||
|               if(skip_empty_lines === true && this.state.wasQuoting === false && this.state.record.length === 0 && this.state.field.length === 0){ | ||||
|                 this.info.empty_lines++ | ||||
|                 pos += recordDelimiterLength - 1 | ||||
|                 continue | ||||
|               } | ||||
|               // Activate records emition if above from_line | ||||
|               if(this.state.enabled === false && this.info.lines + (this.state.wasRowDelimiter === true ? 1: 0 ) >= from_line){ | ||||
|                 this.state.enabled = true | ||||
|                 this.__resetField() | ||||
|                 this.__resetRow() | ||||
|                 pos += recordDelimiterLength - 1 | ||||
|                 continue | ||||
|               }else{ | ||||
|                 const errField = this.__onField() | ||||
|                 if(errField !== undefined) return errField | ||||
|                 const errRecord = this.__onRow() | ||||
|                 if(errRecord !== undefined) return errRecord | ||||
|               } | ||||
|               const errField = this.__onField() | ||||
|               if(errField !== undefined) return errField | ||||
|               const errRecord = this.__onRecord() | ||||
|               if(errRecord !== undefined) return errRecord | ||||
|               if(to !== -1 && this.info.records >= to){ | ||||
|                 this.state.stop = true | ||||
|                 this.push(null) | ||||
| @@ -12366,7 +12408,7 @@ class Parser extends Transform { | ||||
|         if(this.state.wasQuoting === true || this.state.record.length !== 0 || this.state.field.length !== 0){ | ||||
|           const errField = this.__onField() | ||||
|           if(errField !== undefined) return errField | ||||
|           const errRecord = this.__onRow() | ||||
|           const errRecord = this.__onRecord() | ||||
|           if(errRecord !== undefined) return errRecord | ||||
|         }else if(this.state.wasRowDelimiter === true){ | ||||
|           this.info.empty_lines++ | ||||
| @@ -12382,21 +12424,17 @@ class Parser extends Transform { | ||||
|       this.state.wasRowDelimiter = false | ||||
|     } | ||||
|   } | ||||
|   // Helper to test if a character is a space or a line delimiter | ||||
|   __isCharTrimable(chr){ | ||||
|     return chr === space || chr === tab || chr === cr || chr === nl || chr === np | ||||
|   } | ||||
|   __onRow(){ | ||||
|   __onRecord(){ | ||||
|     const {columns, columns_duplicates_to_array, encoding, info, from, relax_column_count, relax_column_count_less, relax_column_count_more, raw, skip_lines_with_empty_values} = this.options | ||||
|     const {enabled, record} = this.state | ||||
|     if(enabled === false){ | ||||
|       return this.__resetRow() | ||||
|       return this.__resetRecord() | ||||
|     } | ||||
|     // Convert the first line into column names | ||||
|     const recordLength = record.length | ||||
|     if(columns === true){ | ||||
|       if(isRecordEmpty(record)){ | ||||
|         this.__resetRow() | ||||
|         this.__resetRecord() | ||||
|         return | ||||
|       } | ||||
|       return this.__firstLineToColumns(record) | ||||
| @@ -12406,47 +12444,44 @@ class Parser extends Transform { | ||||
|     } | ||||
|     if(recordLength !== this.state.expectedRecordLength){ | ||||
|       const err = columns === false ? | ||||
|         this.__error( | ||||
|           // Todo: rename CSV_INCONSISTENT_RECORD_LENGTH to | ||||
|           // CSV_RECORD_INCONSISTENT_FIELDS_LENGTH | ||||
|           new CsvError('CSV_INCONSISTENT_RECORD_LENGTH', [ | ||||
|             'Invalid Record Length:', | ||||
|             `expect ${this.state.expectedRecordLength},`, | ||||
|             `got ${recordLength} on line ${this.info.lines}`, | ||||
|           ], this.options, this.__context(), { | ||||
|             record: record, | ||||
|           }) | ||||
|         ) | ||||
|         // Todo: rename CSV_INCONSISTENT_RECORD_LENGTH to | ||||
|         // CSV_RECORD_INCONSISTENT_FIELDS_LENGTH | ||||
|         new CsvError('CSV_INCONSISTENT_RECORD_LENGTH', [ | ||||
|           'Invalid Record Length:', | ||||
|           `expect ${this.state.expectedRecordLength},`, | ||||
|           `got ${recordLength} on line ${this.info.lines}`, | ||||
|         ], this.options, this.__context(), { | ||||
|           record: record, | ||||
|         }) | ||||
|       : | ||||
|         this.__error( | ||||
|           // Todo: rename CSV_RECORD_DONT_MATCH_COLUMNS_LENGTH to | ||||
|           // CSV_RECORD_INCONSISTENT_COLUMNS | ||||
|           new CsvError('CSV_RECORD_DONT_MATCH_COLUMNS_LENGTH', [ | ||||
|             'Invalid Record Length:', | ||||
|             `columns length is ${columns.length},`, // rename columns | ||||
|             `got ${recordLength} on line ${this.info.lines}`, | ||||
|           ], this.options, this.__context(), { | ||||
|             record: record, | ||||
|           }) | ||||
|         ) | ||||
|         // Todo: rename CSV_RECORD_DONT_MATCH_COLUMNS_LENGTH to | ||||
|         // CSV_RECORD_INCONSISTENT_COLUMNS | ||||
|         new CsvError('CSV_RECORD_DONT_MATCH_COLUMNS_LENGTH', [ | ||||
|           'Invalid Record Length:', | ||||
|           `columns length is ${columns.length},`, // rename columns | ||||
|           `got ${recordLength} on line ${this.info.lines}`, | ||||
|         ], this.options, this.__context(), { | ||||
|           record: record, | ||||
|         }) | ||||
|       if(relax_column_count === true ||  | ||||
|         (relax_column_count_less === true && recordLength < this.state.expectedRecordLength) || | ||||
|         (relax_column_count_more === true && recordLength > this.state.expectedRecordLength) ){ | ||||
|         this.info.invalid_field_length++ | ||||
|         this.state.error = err | ||||
|       // Error is undefined with skip_lines_with_error | ||||
|       }else if(err !== undefined){ | ||||
|         return err | ||||
|       }else{ | ||||
|         const finalErr = this.__error(err) | ||||
|         if(finalErr) return finalErr | ||||
|       } | ||||
|     } | ||||
|     if(skip_lines_with_empty_values === true){ | ||||
|       if(isRecordEmpty(record)){ | ||||
|         this.__resetRow() | ||||
|         this.__resetRecord() | ||||
|         return | ||||
|       } | ||||
|     } | ||||
|     if(this.state.recordHasError === true){ | ||||
|       this.__resetRow() | ||||
|       this.__resetRecord() | ||||
|       this.state.recordHasError = false | ||||
|       return | ||||
|     } | ||||
| @@ -12520,7 +12555,7 @@ class Parser extends Transform { | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     this.__resetRow() | ||||
|     this.__resetRecord() | ||||
|   } | ||||
|   __firstLineToColumns(record){ | ||||
|     const {firstLineToHeaders} = this.state | ||||
| @@ -12540,13 +12575,13 @@ class Parser extends Transform { | ||||
|       const normalizedHeaders = normalizeColumnsArray(headers) | ||||
|       this.state.expectedRecordLength = normalizedHeaders.length | ||||
|       this.options.columns = normalizedHeaders | ||||
|       this.__resetRow() | ||||
|       this.__resetRecord() | ||||
|       return | ||||
|     }catch(err){ | ||||
|       return err | ||||
|     } | ||||
|   } | ||||
|   __resetRow(){ | ||||
|   __resetRecord(){ | ||||
|     if(this.options.raw === true){ | ||||
|       this.state.rawBuffer.reset() | ||||
|     } | ||||
| @@ -12619,6 +12654,10 @@ class Parser extends Transform { | ||||
|     } | ||||
|     return [undefined, field] | ||||
|   } | ||||
|   // Helper to test if a character is a space or a line delimiter | ||||
|   __isCharTrimable(chr){ | ||||
|     return chr === space || chr === tab || chr === cr || chr === nl || chr === np | ||||
|   } | ||||
|   // Keep it in case we implement the `cast_int` option | ||||
|   // __isInt(value){ | ||||
|   //   // return Number.isInteger(parseInt(value)) | ||||
| @@ -12645,14 +12684,19 @@ class Parser extends Transform { | ||||
|       needMoreDataSize, | ||||
|       // Skip if the remaining buffer smaller than record delimiter | ||||
|       recordDelimiterMaxLength, | ||||
|       // Skip if the remaining buffer can be row delimiter following the closing quote | ||||
|       // Skip if the remaining buffer can be record delimiter following the closing quote | ||||
|       // 1 is for quote.length | ||||
|       quoting ? (quote.length + recordDelimiterMaxLength) : 0, | ||||
|     ) | ||||
|     return numOfCharLeft < requiredLength | ||||
|   } | ||||
|   __isDelimiter(buf, pos, chr){ | ||||
|     const {delimiter} = this.options | ||||
|     const {delimiter, ignore_last_delimiters} = this.options | ||||
|     if(ignore_last_delimiters === true && this.state.record.length === this.options.columns.length - 1){ | ||||
|       return 0 | ||||
|     }else if(ignore_last_delimiters !== false && typeof ignore_last_delimiters === 'number' && this.state.record.length === ignore_last_delimiters - 1){ | ||||
|       return 0 | ||||
|     } | ||||
|     loop1: for(let i = 0; i < delimiter.length; i++){ | ||||
|       const del = delimiter[i] | ||||
|       if(del[0] === chr){ | ||||
| @@ -12707,7 +12751,7 @@ class Parser extends Transform { | ||||
|     } | ||||
|     return true | ||||
|   } | ||||
|   __autoDiscoverRowDelimiter(buf, pos){ | ||||
|   __autoDiscoverRecordDelimiter(buf, pos){ | ||||
|     const {encoding} = this.options | ||||
|     const chr = buf[pos] | ||||
|     if(chr === cr){ | ||||
| @@ -12970,7 +13014,7 @@ let _defaultContext, _tmpDir; | ||||
| function defaultContext() { | ||||
|     var _a, _b; | ||||
|     if (!_defaultContext) { | ||||
|         _defaultContext = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}.git#${(_b = (_a = github.context) === null || _a === void 0 ? void 0 : _a.ref) === null || _b === void 0 ? void 0 : _b.replace(/^refs\//, '')}`; | ||||
|         _defaultContext = `${process.env.GITHUB_SERVER_URL || 'https://github.com'}/${github.context.repo.owner}/${github.context.repo.repo}.git#${(_b = (_a = github.context) === null || _a === void 0 ? void 0 : _a.ref) === null || _b === void 0 ? void 0 : _b.replace(/^refs\//, '')}`; | ||||
|     } | ||||
|     return _defaultContext; | ||||
| } | ||||
| @@ -12989,25 +13033,27 @@ exports.tmpNameSync = tmpNameSync; | ||||
| function getInputs(defaultContext) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         return { | ||||
|             context: core.getInput('context') || defaultContext, | ||||
|             file: core.getInput('file') || 'Dockerfile', | ||||
|             buildArgs: yield getInputList('build-args', true), | ||||
|             labels: yield getInputList('labels', true), | ||||
|             tags: yield getInputList('tags'), | ||||
|             pull: /true/i.test(core.getInput('pull')), | ||||
|             target: core.getInput('target'), | ||||
|             allow: yield getInputList('allow'), | ||||
|             noCache: /true/i.test(core.getInput('no-cache')), | ||||
|             buildArgs: yield getInputList('build-args', true), | ||||
|             builder: core.getInput('builder'), | ||||
|             platforms: yield getInputList('platforms'), | ||||
|             load: /true/i.test(core.getInput('load')), | ||||
|             push: /true/i.test(core.getInput('push')), | ||||
|             outputs: yield getInputList('outputs', true), | ||||
|             cacheFrom: yield getInputList('cache-from', true), | ||||
|             cacheTo: yield getInputList('cache-to', true), | ||||
|             context: core.getInput('context') || defaultContext, | ||||
|             file: core.getInput('file'), | ||||
|             labels: yield getInputList('labels', true), | ||||
|             load: /true/i.test(core.getInput('load')), | ||||
|             network: core.getInput('network'), | ||||
|             noCache: /true/i.test(core.getInput('no-cache')), | ||||
|             outputs: yield getInputList('outputs', true), | ||||
|             platforms: yield getInputList('platforms'), | ||||
|             pull: /true/i.test(core.getInput('pull')), | ||||
|             push: /true/i.test(core.getInput('push')), | ||||
|             secrets: yield getInputList('secrets', true), | ||||
|             githubToken: core.getInput('github-token'), | ||||
|             ssh: yield getInputList('ssh') | ||||
|             secretFiles: yield getInputList('secret-files', true), | ||||
|             ssh: yield getInputList('ssh'), | ||||
|             tags: yield getInputList('tags'), | ||||
|             target: core.getInput('target'), | ||||
|             githubToken: core.getInput('github-token') | ||||
|         }; | ||||
|     }); | ||||
| } | ||||
| @@ -13058,14 +13104,22 @@ function getBuildArgs(inputs, defaultContext, buildxVersion) { | ||||
|         })); | ||||
|         yield exports.asyncForEach(inputs.secrets, (secret) => __awaiter(this, void 0, void 0, function* () { | ||||
|             try { | ||||
|                 args.push('--secret', yield buildx.getSecret(secret)); | ||||
|                 args.push('--secret', yield buildx.getSecretString(secret)); | ||||
|             } | ||||
|             catch (err) { | ||||
|                 core.warning(err.message); | ||||
|             } | ||||
|         })); | ||||
|         yield exports.asyncForEach(inputs.secretFiles, (secretFile) => __awaiter(this, void 0, void 0, function* () { | ||||
|             try { | ||||
|                 args.push('--secret', yield buildx.getSecretFile(secretFile)); | ||||
|             } | ||||
|             catch (err) { | ||||
|                 core.warning(err.message); | ||||
|             } | ||||
|         })); | ||||
|         if (inputs.githubToken && !buildx.hasGitAuthToken(inputs.secrets) && inputs.context == defaultContext) { | ||||
|             args.push('--secret', yield buildx.getSecret(`GIT_AUTH_TOKEN=${inputs.githubToken}`)); | ||||
|             args.push('--secret', yield buildx.getSecretString(`GIT_AUTH_TOKEN=${inputs.githubToken}`)); | ||||
|         } | ||||
|         yield exports.asyncForEach(inputs.ssh, (ssh) => __awaiter(this, void 0, void 0, function* () { | ||||
|             args.push('--ssh', ssh); | ||||
| @@ -13091,6 +13145,9 @@ function getCommonArgs(inputs) { | ||||
|         if (inputs.load) { | ||||
|             args.push('--load'); | ||||
|         } | ||||
|         if (inputs.network) { | ||||
|             args.push('--network', inputs.network); | ||||
|         } | ||||
|         if (inputs.push) { | ||||
|             args.push('--push'); | ||||
|         } | ||||
| @@ -13149,22 +13206,30 @@ module.exports = clean | ||||
| /***/ (function(module, __unusedexports, __webpack_require__) { | ||||
|  | ||||
| const Range = __webpack_require__(828) | ||||
| const { ANY } = __webpack_require__(532) | ||||
| const Comparator = __webpack_require__(532) | ||||
| const { ANY } = Comparator | ||||
| const satisfies = __webpack_require__(55) | ||||
| const compare = __webpack_require__(309) | ||||
|  | ||||
| // Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff: | ||||
| // - Every simple range `r1, r2, ...` is a subset of some `R1, R2, ...` | ||||
| // - Every simple range `r1, r2, ...` is a null set, OR | ||||
| // - Every simple range `r1, r2, ...` which is not a null set is a subset of | ||||
| //   some `R1, R2, ...` | ||||
| // | ||||
| // Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff: | ||||
| // - If c is only the ANY comparator | ||||
| //   - If C is only the ANY comparator, return true | ||||
| //   - Else return false | ||||
| //   - Else if in prerelease mode, return false | ||||
| //   - else replace c with `[>=0.0.0]` | ||||
| // - If C is only the ANY comparator | ||||
| //   - if in prerelease mode, return true | ||||
| //   - else replace C with `[>=0.0.0]` | ||||
| // - Let EQ be the set of = comparators in c | ||||
| // - If EQ is more than one, return true (null set) | ||||
| // - Let GT be the highest > or >= comparator in c | ||||
| // - Let LT be the lowest < or <= comparator in c | ||||
| // - If GT and LT, and GT.semver > LT.semver, return true (null set) | ||||
| // - If any C is a = range, and GT or LT are set, return false | ||||
| // - If EQ | ||||
| //   - If GT, and EQ does not satisfy GT, return true (null set) | ||||
| //   - If LT, and EQ does not satisfy LT, return true (null set) | ||||
| @@ -13173,13 +13238,16 @@ const compare = __webpack_require__(309) | ||||
| // - If GT | ||||
| //   - If GT.semver is lower than any > or >= comp in C, return false | ||||
| //   - If GT is >=, and GT.semver does not satisfy every C, return false | ||||
| //   - If GT.semver has a prerelease, and not in prerelease mode | ||||
| //     - If no C has a prerelease and the GT.semver tuple, return false | ||||
| // - If LT | ||||
| //   - If LT.semver is greater than any < or <= comp in C, return false | ||||
| //   - If LT is <=, and LT.semver does not satisfy every C, return false | ||||
| // - If any C is a = range, and GT or LT are set, return false | ||||
| //   - If GT.semver has a prerelease, and not in prerelease mode | ||||
| //     - If no C has a prerelease and the LT.semver tuple, return false | ||||
| // - Else return true | ||||
|  | ||||
| const subset = (sub, dom, options) => { | ||||
| const subset = (sub, dom, options = {}) => { | ||||
|   if (sub === dom) | ||||
|     return true | ||||
|  | ||||
| @@ -13208,8 +13276,21 @@ const simpleSubset = (sub, dom, options) => { | ||||
|   if (sub === dom) | ||||
|     return true | ||||
|  | ||||
|   if (sub.length === 1 && sub[0].semver === ANY) | ||||
|     return dom.length === 1 && dom[0].semver === ANY | ||||
|   if (sub.length === 1 && sub[0].semver === ANY) { | ||||
|     if (dom.length === 1 && dom[0].semver === ANY) | ||||
|       return true | ||||
|     else if (options.includePrerelease) | ||||
|       sub = [ new Comparator('>=0.0.0-0') ] | ||||
|     else | ||||
|       sub = [ new Comparator('>=0.0.0') ] | ||||
|   } | ||||
|  | ||||
|   if (dom.length === 1 && dom[0].semver === ANY) { | ||||
|     if (options.includePrerelease) | ||||
|       return true | ||||
|     else | ||||
|       dom = [ new Comparator('>=0.0.0') ] | ||||
|   } | ||||
|  | ||||
|   const eqSet = new Set() | ||||
|   let gt, lt | ||||
| @@ -13252,10 +13333,32 @@ const simpleSubset = (sub, dom, options) => { | ||||
|  | ||||
|   let higher, lower | ||||
|   let hasDomLT, hasDomGT | ||||
|   // if the subset has a prerelease, we need a comparator in the superset | ||||
|   // with the same tuple and a prerelease, or it's not a subset | ||||
|   let needDomLTPre = lt && | ||||
|     !options.includePrerelease && | ||||
|     lt.semver.prerelease.length ? lt.semver : false | ||||
|   let needDomGTPre = gt && | ||||
|     !options.includePrerelease && | ||||
|     gt.semver.prerelease.length ? gt.semver : false | ||||
|   // exception: <1.2.3-0 is the same as <1.2.3 | ||||
|   if (needDomLTPre && needDomLTPre.prerelease.length === 1 && | ||||
|       lt.operator === '<' && needDomLTPre.prerelease[0] === 0) { | ||||
|     needDomLTPre = false | ||||
|   } | ||||
|  | ||||
|   for (const c of dom) { | ||||
|     hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=' | ||||
|     hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=' | ||||
|     if (gt) { | ||||
|       if (needDomGTPre) { | ||||
|         if (c.semver.prerelease && c.semver.prerelease.length && | ||||
|             c.semver.major === needDomGTPre.major && | ||||
|             c.semver.minor === needDomGTPre.minor && | ||||
|             c.semver.patch === needDomGTPre.patch) { | ||||
|           needDomGTPre = false | ||||
|         } | ||||
|       } | ||||
|       if (c.operator === '>' || c.operator === '>=') { | ||||
|         higher = higherGT(gt, c, options) | ||||
|         if (higher === c && higher !== gt) | ||||
| @@ -13264,6 +13367,14 @@ const simpleSubset = (sub, dom, options) => { | ||||
|         return false | ||||
|     } | ||||
|     if (lt) { | ||||
|       if (needDomLTPre) { | ||||
|         if (c.semver.prerelease && c.semver.prerelease.length && | ||||
|             c.semver.major === needDomLTPre.major && | ||||
|             c.semver.minor === needDomLTPre.minor && | ||||
|             c.semver.patch === needDomLTPre.patch) { | ||||
|           needDomLTPre = false | ||||
|         } | ||||
|       } | ||||
|       if (c.operator === '<' || c.operator === '<=') { | ||||
|         lower = lowerLT(lt, c, options) | ||||
|         if (lower === c && lower !== lt) | ||||
| @@ -13284,6 +13395,12 @@ const simpleSubset = (sub, dom, options) => { | ||||
|   if (lt && hasDomGT && !gt && gtltComp !== 0) | ||||
|     return false | ||||
|  | ||||
|   // we needed a prerelease range in a specific tuple, but didn't get one | ||||
|   // then this isn't a subset.  eg >=1.2.3-pre is not a subset of >=1.0.0, | ||||
|   // because it includes prereleases in the 1.2.3 tuple | ||||
|   if (needDomGTPre || needDomLTPre) | ||||
|     return false | ||||
|  | ||||
|   return true | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,42 +1,67 @@ | ||||
| variable "NODE_VERSION" { | ||||
|   default = "12" | ||||
| } | ||||
|  | ||||
| target "node-version" { | ||||
|   args = { | ||||
|     NODE_VERSION = NODE_VERSION | ||||
|   } | ||||
| } | ||||
|  | ||||
| group "default" { | ||||
|   targets = ["build"] | ||||
| } | ||||
|  | ||||
| group "pre-checkin" { | ||||
|   targets = ["update-yarn", "format", "build"] | ||||
|   targets = ["vendor-update", "format", "build"] | ||||
| } | ||||
|  | ||||
| group "validate" { | ||||
| 	targets = ["validate-format", "validate-build", "validate-yarn"] | ||||
| } | ||||
|  | ||||
| target "update-yarn" { | ||||
|   target = "update-yarn" | ||||
|   output = ["."] | ||||
|   targets = ["format-validate", "build-validate", "vendor-validate"] | ||||
| } | ||||
|  | ||||
| target "build" { | ||||
|   target = "dist" | ||||
|   inherits = ["node-version"] | ||||
|   dockerfile = "./hack/build.Dockerfile" | ||||
|   target = "build-update" | ||||
|   output = ["."] | ||||
| } | ||||
|  | ||||
| target "test" { | ||||
|   target = "test" | ||||
| target "build-validate" { | ||||
|   inherits = ["node-version"] | ||||
|   dockerfile = "./hack/build.Dockerfile" | ||||
|   target = "build-validate" | ||||
| } | ||||
|  | ||||
| target "format" { | ||||
|   target = "format" | ||||
|   inherits = ["node-version"] | ||||
|   dockerfile = "./hack/build.Dockerfile" | ||||
|   target = "format-update" | ||||
|   output = ["."] | ||||
| } | ||||
|  | ||||
| target "validate-format" { | ||||
|   target = "validate-format" | ||||
| target "format-validate" { | ||||
|   inherits = ["node-version"] | ||||
|   dockerfile = "./hack/build.Dockerfile" | ||||
|   target = "format-validate" | ||||
| } | ||||
|  | ||||
| target "validate-build" { | ||||
|   target = "validate-build" | ||||
| target "vendor-update" { | ||||
|   inherits = ["node-version"] | ||||
|   dockerfile = "./hack/vendor.Dockerfile" | ||||
|   target = "update" | ||||
|   output = ["."] | ||||
| } | ||||
|  | ||||
| target "validate-yarn" { | ||||
| 	target = "validate-yarn" | ||||
| target "vendor-validate" { | ||||
|   inherits = ["node-version"] | ||||
|   dockerfile = "./hack/vendor.Dockerfile" | ||||
|   target = "validate" | ||||
| } | ||||
|  | ||||
| target "test" { | ||||
|   inherits = ["node-version"] | ||||
|   dockerfile = "./hack/test.Dockerfile" | ||||
|   target = "test-coverage" | ||||
|   output = ["./coverage"] | ||||
| } | ||||
|   | ||||
							
								
								
									
										107
									
								
								docs/advanced/cache.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								docs/advanced/cache.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,107 @@ | ||||
| # Cache | ||||
|  | ||||
| * [Registry cache](#registry-cache) | ||||
| * [GitHub cache](#github-cache) | ||||
|  | ||||
| > More info about buildx cache: https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#cache-from | ||||
|  | ||||
| ## Registry cache | ||||
|  | ||||
| You can import/export cache from a cache manifest or (special) image configuration on the registry. | ||||
|  | ||||
| ```yaml | ||||
| name: ci | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - 'master' | ||||
|  | ||||
| jobs: | ||||
|   docker: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|       - | ||||
|         name: Login to DockerHub | ||||
|         uses: docker/login-action@v1  | ||||
|         with: | ||||
|           username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|           password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
|       - | ||||
|         name: Build and push | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           context: . | ||||
|           push: true | ||||
|           tags: user/app:latest | ||||
|           cache-from: type=registry,ref=user/app:latest | ||||
|           cache-to: type=inline | ||||
| ``` | ||||
|  | ||||
| ## GitHub cache | ||||
|  | ||||
| > :warning: At the moment caches are copied over the existing cache so it [keeps growing](https://github.com/docker/build-push-action/issues/252). | ||||
| > The `Move cache` step is used as a temporary fix (see https://github.com/moby/buildkit/issues/1896). | ||||
|  | ||||
| > :rocket: There is a new cache backend using GitHub cache being developed that will lighten your workflow. | ||||
| > More info: https://github.com/docker/buildx/pull/535 | ||||
|  | ||||
| You can leverage [GitHub cache](https://docs.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows) | ||||
| using [actions/cache](https://github.com/actions/cache) with this action: | ||||
|  | ||||
| ```yaml | ||||
| name: ci | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - 'master' | ||||
|  | ||||
| jobs: | ||||
|   docker: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|       - | ||||
|         name: Cache Docker layers | ||||
|         uses: actions/cache@v2 | ||||
|         with: | ||||
|           path: /tmp/.buildx-cache | ||||
|           key: ${{ runner.os }}-buildx-${{ github.sha }} | ||||
|           restore-keys: | | ||||
|             ${{ runner.os }}-buildx- | ||||
|       - | ||||
|         name: Login to DockerHub | ||||
|         uses: docker/login-action@v1  | ||||
|         with: | ||||
|           username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|           password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
|       - | ||||
|         name: Build and push | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           context: . | ||||
|           push: true | ||||
|           tags: user/app:latest | ||||
|           cache-from: type=local,src=/tmp/.buildx-cache | ||||
|           cache-to: type=local,dest=/tmp/.buildx-cache-new | ||||
|       - | ||||
|         # Temp fix | ||||
|         # https://github.com/docker/build-push-action/issues/252 | ||||
|         # https://github.com/moby/buildkit/issues/1896 | ||||
|         name: Move cache | ||||
|         run: | | ||||
|           rm -rf /tmp/.buildx-cache | ||||
|           mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||||
| ``` | ||||
							
								
								
									
										48
									
								
								docs/advanced/dockerhub-desc.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								docs/advanced/dockerhub-desc.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| # Update DockerHub repo description | ||||
|  | ||||
| You can update the [DockerHub repository description](https://docs.docker.com/docker-hub/repos/) using | ||||
| a third party action called [DockerHub Description](https://github.com/peter-evans/dockerhub-description) | ||||
| with this action: | ||||
|  | ||||
| ```yaml | ||||
| name: ci | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - 'master' | ||||
|  | ||||
| jobs: | ||||
|   docker: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@v1 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|       - | ||||
|         name: Login to DockerHub | ||||
|         uses: docker/login-action@v1  | ||||
|         with: | ||||
|           username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|           password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
|       - | ||||
|         name: Build and push | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           context: . | ||||
|           push: true | ||||
|           tags: user/app:latest | ||||
|       - | ||||
|         name: Update repo description | ||||
|         uses: peter-evans/dockerhub-description@v2 | ||||
|         with: | ||||
|           username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|           password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||||
|           repository: user/app | ||||
| ``` | ||||
							
								
								
									
										35
									
								
								docs/advanced/export-docker.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								docs/advanced/export-docker.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| # Export image to Docker | ||||
|  | ||||
| You may want your build result to be available in the Docker client through `docker images` to be able to use it | ||||
| in another step of your workflow: | ||||
|  | ||||
| ```yaml | ||||
| name: ci | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - 'master' | ||||
|  | ||||
| jobs: | ||||
|   docker: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|       - | ||||
|         name: Build | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           context: . | ||||
|           load: true | ||||
|           tags: myimage:latest | ||||
|       - | ||||
|         name: Inspect | ||||
|         run: | | ||||
|           docker image inspect myimage:latest | ||||
| ``` | ||||
							
								
								
									
										44
									
								
								docs/advanced/isolated-builders.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								docs/advanced/isolated-builders.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | ||||
| # Isolated builders | ||||
|  | ||||
| ```yaml | ||||
| name: ci | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - 'master' | ||||
|  | ||||
| jobs: | ||||
|   docker: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|         id: builder1 | ||||
|       - | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|         id: builder2 | ||||
|       - | ||||
|         name: Builder 1 name | ||||
|         run: echo ${{ steps.builder1.outputs.name }} | ||||
|       - | ||||
|         name: Builder 2 name | ||||
|         run: echo ${{ steps.builder2.outputs.name }} | ||||
|       - | ||||
|         name: Build against builder1 | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           builder: ${{ steps.builder1.outputs.name }} | ||||
|           context: . | ||||
|           target: mytarget1 | ||||
|       - | ||||
|         name: Build against builder2 | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           builder: ${{ steps.builder2.outputs.name }} | ||||
|           context: . | ||||
|           target: mytarget2 | ||||
| ``` | ||||
							
								
								
									
										44
									
								
								docs/advanced/local-registry.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								docs/advanced/local-registry.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | ||||
| # Local registry | ||||
|  | ||||
| For testing purposes you may need to create a [local registry](https://hub.docker.com/_/registry) to push images into: | ||||
|  | ||||
| ```yaml | ||||
| name: ci | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - 'master' | ||||
|  | ||||
| jobs: | ||||
|   docker: | ||||
|     runs-on: ubuntu-latest | ||||
|     services: | ||||
|       registry: | ||||
|         image: registry:2 | ||||
|         ports: | ||||
|           - 5000:5000 | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@v1 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|         with: | ||||
|           driver-opts: network=host | ||||
|       - | ||||
|         name: Build and push to local registry | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           context: . | ||||
|           push: true | ||||
|           tags: localhost:5000/name/app:latest | ||||
|       - | ||||
|         name: Inspect | ||||
|         run: | | ||||
|           docker buildx imagetools inspect localhost:5000/name/app:latest | ||||
| ``` | ||||
							
								
								
									
										44
									
								
								docs/advanced/multi-platform.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								docs/advanced/multi-platform.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | ||||
| # Multi-platform image | ||||
|  | ||||
| You can build multi-platform images using the [`platforms` input](../../README.md#inputs) as described below. | ||||
|  | ||||
| > :bulb: List of available platforms will be displayed and available through our [setup-buildx](https://github.com/docker/setup-buildx-action#about) action. | ||||
|  | ||||
| > :bulb: If you want support for more platforms, you can use QEMU with our [setup-qemu](https://github.com/docker/setup-qemu-action) action. | ||||
|  | ||||
| ```yaml | ||||
| name: ci | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - 'master' | ||||
|  | ||||
| jobs: | ||||
|   docker: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@v1 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|       - | ||||
|         name: Login to DockerHub | ||||
|         uses: docker/login-action@v1  | ||||
|         with: | ||||
|           username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|           password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
|       - | ||||
|         name: Build and push | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           context: . | ||||
|           platforms: linux/amd64,linux/arm64 | ||||
|           push: true | ||||
|           tags: user/app:latest | ||||
| ``` | ||||
							
								
								
									
										57
									
								
								docs/advanced/push-multi-registries.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								docs/advanced/push-multi-registries.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| # Push to multi-registries | ||||
|  | ||||
| * [Docker Hub and GHCR](#docker-hub-and-ghcr) | ||||
|  | ||||
| ## Docker Hub and GHCR | ||||
|  | ||||
| The following workflow will connect you to [DockerHub](https://github.com/docker/login-action#dockerhub) | ||||
| and [GitHub Container Registry](https://github.com/docker/login-action#github-container-registry) and push the | ||||
| image to these registries. | ||||
|  | ||||
| ```yaml | ||||
| name: ci | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - 'master' | ||||
|  | ||||
| jobs: | ||||
|   docker: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@v1 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|       - | ||||
|         name: Login to DockerHub | ||||
|         uses: docker/login-action@v1  | ||||
|         with: | ||||
|           username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|           password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
|       - | ||||
|         name: Login to GitHub Container Registry | ||||
|         uses: docker/login-action@v1  | ||||
|         with: | ||||
|           registry: ghcr.io | ||||
|           username: ${{ github.repository_owner }} | ||||
|           password: ${{ secrets.GITHUB_TOKEN }} | ||||
|       - | ||||
|         name: Build and push | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           context: . | ||||
|           platforms: linux/amd64,linux/arm64 | ||||
|           push: true | ||||
|           tags: | | ||||
|             user/app:latest | ||||
|             user/app:1.0.0 | ||||
|             ghcr.io/user/app:latest | ||||
|             ghcr.io/user/app:1.0.0 | ||||
| ``` | ||||
							
								
								
									
										84
									
								
								docs/advanced/secrets.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								docs/advanced/secrets.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,84 @@ | ||||
| # Secrets | ||||
|  | ||||
| In the following example we will expose and use the [GITHUB_TOKEN secret](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret) | ||||
| as provided by GitHub in your workflow. | ||||
|  | ||||
| First let's create our `Dockerfile` to use our secret: | ||||
|  | ||||
| ```Dockerfile | ||||
| #syntax=docker/dockerfile:1.2 | ||||
|  | ||||
| FROM alpine | ||||
| RUN --mount=type=secret,id=github_token \ | ||||
|   cat /run/secrets/github_token | ||||
| ``` | ||||
|  | ||||
| As you can see we have named our secret `github_token`. Here is the workflow you can use to expose this secret using | ||||
| the [`secrets` input](../../README.md#inputs): | ||||
|  | ||||
| ```yaml | ||||
| name: ci | ||||
|  | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - 'master' | ||||
|  | ||||
| jobs: | ||||
|   docker: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@v1 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|       - | ||||
|         name: Build | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           context: . | ||||
|           platforms: linux/amd64,linux/arm64 | ||||
|           tags: user/app:latest | ||||
|           secrets: | | ||||
|             "github_token=${{ secrets.GITHUB_TOKEN }}" | ||||
| ``` | ||||
|  | ||||
| > :bulb: You can also expose a secret file to the build with [`secret-files`](../../README.md#inputs) input: | ||||
| > ```yaml | ||||
| > secret-files: | | ||||
| >   "MY_SECRET=./secret.txt" | ||||
| > ``` | ||||
|  | ||||
| If you're using [GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) and need to handle | ||||
| multi-line value, you will need to place the key-value pair between quotes: | ||||
|  | ||||
| ```yaml | ||||
| secrets: | | ||||
|   "MYSECRET=${{ secrets.GPG_KEY }}" | ||||
|   GIT_AUTH_TOKEN=abcdefghi,jklmno=0123456789 | ||||
|   "MYSECRET=aaaaaaaa | ||||
|   bbbbbbb | ||||
|   ccccccccc" | ||||
|   FOO=bar | ||||
|   "EMPTYLINE=aaaa | ||||
|    | ||||
|   bbbb | ||||
|   ccc" | ||||
|   "JSON_SECRET={""key1"":""value1"",""key2"":""value2""}" | ||||
| ``` | ||||
|  | ||||
| | Key                | Value                                            | | ||||
| |--------------------|--------------------------------------------------| | ||||
| | `MYSECRET`         | `***********************` | | ||||
| | `GIT_AUTH_TOKEN`   | `abcdefghi,jklmno=0123456789` | | ||||
| | `MYSECRET`         | `aaaaaaaa\nbbbbbbb\nccccccccc` | | ||||
| | `FOO`              | `bar` | | ||||
| | `EMPTYLINE`        | `aaaa\n\nbbbb\nccc` | | ||||
| | `JSON_SECRET`      | `{"key1":"value1","key2":"value2"}` | | ||||
|  | ||||
| > :bulb: All quote signs need to be doubled for escaping. | ||||
							
								
								
									
										77
									
								
								docs/advanced/tags-labels.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								docs/advanced/tags-labels.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,77 @@ | ||||
| # Handle tags and labels | ||||
|  | ||||
| If you come from [`v1`](https://github.com/docker/build-push-action/tree/releases/v1#readme) and want an | ||||
| "automatic" tag management and [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md) | ||||
| for labels, you can do it in a dedicated step. The following workflow will use the [Docker meta action](https://github.com/crazy-max/ghaction-docker-meta) | ||||
| to handle tags and labels based on GitHub actions events and Git metadata. | ||||
|  | ||||
| ```yaml | ||||
| name: ci | ||||
|  | ||||
| on: | ||||
|   schedule: | ||||
|     - cron: '0 10 * * *' # everyday at 10am | ||||
|   push: | ||||
|     branches: | ||||
|       - '**' | ||||
|     tags: | ||||
|       - 'v*.*.*' | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - 'master' | ||||
|  | ||||
| jobs: | ||||
|   docker: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - | ||||
|         name: Checkout | ||||
|         uses: actions/checkout@v2 | ||||
|       - | ||||
|         name: Docker meta | ||||
|         id: meta | ||||
|         uses: crazy-max/ghaction-docker-meta@v2 | ||||
|         with: | ||||
|           # list of Docker images to use as base name for tags | ||||
|           images: | | ||||
|             name/app | ||||
|             ghcr.io/username/app | ||||
|           # generate Docker tags based on the following events/attributes | ||||
|           tags: | | ||||
|             type=schedule | ||||
|             type=ref,event=branch | ||||
|             type=ref,event=pr | ||||
|             type=semver,pattern={{version}} | ||||
|             type=semver,pattern={{major}}.{{minor}} | ||||
|             type=semver,pattern={{major}} | ||||
|             type=sha | ||||
|       - | ||||
|         name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@v1 | ||||
|       - | ||||
|         name: Set up Docker Buildx | ||||
|         uses: docker/setup-buildx-action@v1 | ||||
|       - | ||||
|         name: Login to DockerHub | ||||
|         if: github.event_name != 'pull_request' | ||||
|         uses: docker/login-action@v1  | ||||
|         with: | ||||
|           username: ${{ secrets.DOCKERHUB_USERNAME }} | ||||
|           password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
|       - | ||||
|         name: Login to GHCR | ||||
|         if: github.event_name != 'pull_request' | ||||
|         uses: docker/login-action@v1 | ||||
|         with: | ||||
|           registry: ghcr.io | ||||
|           username: ${{ github.repository_owner }} | ||||
|           password: ${{ secrets.GITHUB_TOKEN }} | ||||
|       - | ||||
|         name: Build and push | ||||
|         uses: docker/build-push-action@v2 | ||||
|         with: | ||||
|           context: . | ||||
|           push: ${{ github.event_name != 'pull_request' }} | ||||
|           tags: ${{ steps.meta.outputs.tags }} | ||||
|           labels: ${{ steps.meta.outputs.labels }} | ||||
| ``` | ||||
							
								
								
									
										42
									
								
								hack/build.Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								hack/build.Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| # syntax=docker/dockerfile:1.2 | ||||
| ARG NODE_VERSION | ||||
|  | ||||
| FROM node:${NODE_VERSION}-alpine AS base | ||||
| RUN apk add --no-cache cpio findutils git | ||||
| WORKDIR /src | ||||
|  | ||||
| FROM base AS deps | ||||
| RUN --mount=type=bind,target=.,rw \ | ||||
|   --mount=type=cache,target=/src/node_modules \ | ||||
|   yarn install | ||||
|  | ||||
| FROM deps AS build | ||||
| RUN --mount=type=bind,target=.,rw \ | ||||
|   --mount=type=cache,target=/src/node_modules \ | ||||
|   yarn run build && mkdir /out && cp -Rf dist /out/ | ||||
|  | ||||
| FROM scratch AS build-update | ||||
| COPY --from=build /out / | ||||
|  | ||||
| FROM build AS build-validate | ||||
| RUN --mount=type=bind,target=.,rw \ | ||||
|   git add -A && cp -rf /out/* .; \ | ||||
|   if [ -n "$(git status --porcelain -- dist)" ]; then \ | ||||
|     echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'; \ | ||||
|     git status --porcelain -- dist; \ | ||||
|     exit 1; \ | ||||
|   fi | ||||
|  | ||||
| FROM deps AS format | ||||
| RUN --mount=type=bind,target=.,rw \ | ||||
|   --mount=type=cache,target=/src/node_modules \ | ||||
|   yarn run format \ | ||||
|   && mkdir /out && find . -name '*.ts' -not -path './node_modules/*' | cpio -pdm /out | ||||
|  | ||||
| FROM scratch AS format-update | ||||
| COPY --from=format /out / | ||||
|  | ||||
| FROM deps AS format-validate | ||||
| RUN --mount=type=bind,target=.,rw \ | ||||
|   --mount=type=cache,target=/src/node_modules \ | ||||
|   yarn run format-check \ | ||||
							
								
								
									
										23
									
								
								hack/test.Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								hack/test.Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| # syntax=docker/dockerfile:1.2 | ||||
| ARG NODE_VERSION | ||||
|  | ||||
| FROM node:${NODE_VERSION}-alpine AS base | ||||
| RUN apk add --no-cache git | ||||
| WORKDIR /src | ||||
|  | ||||
| FROM base AS deps | ||||
| RUN --mount=type=bind,target=.,rw \ | ||||
|   --mount=type=cache,target=/src/node_modules \ | ||||
|   yarn install | ||||
|  | ||||
| FROM deps AS test | ||||
| ENV RUNNER_TEMP=/tmp/github_runner | ||||
| ENV RUNNER_TOOL_CACHE=/tmp/github_tool_cache | ||||
| RUN --mount=type=bind,target=.,rw \ | ||||
|   --mount=type=cache,target=/src/node_modules \ | ||||
|   --mount=type=bind,from=crazymax/docker,source=/usr/libexec/docker/cli-plugins/docker-buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \ | ||||
|   --mount=type=bind,from=crazymax/docker,source=/usr/local/bin/docker,target=/usr/bin/docker \ | ||||
|   yarn run test --coverageDirectory=/tmp/coverage | ||||
|  | ||||
| FROM scratch AS test-coverage | ||||
| COPY --from=test /tmp/coverage / | ||||
							
								
								
									
										23
									
								
								hack/vendor.Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								hack/vendor.Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| # syntax=docker/dockerfile:1.2 | ||||
| ARG NODE_VERSION | ||||
|  | ||||
| FROM node:${NODE_VERSION}-alpine AS base | ||||
| RUN apk add --no-cache git | ||||
| WORKDIR /src | ||||
|  | ||||
| FROM base AS vendored | ||||
| RUN --mount=type=bind,target=.,rw \ | ||||
|   --mount=type=cache,target=/src/node_modules \ | ||||
|   yarn install && mkdir /out && cp yarn.lock /out | ||||
|  | ||||
| FROM scratch AS update | ||||
| COPY --from=vendored /out / | ||||
|  | ||||
| FROM vendored AS validate | ||||
| RUN --mount=type=bind,target=.,rw \ | ||||
|   git add -A && cp -rf /out/* .; \ | ||||
|   if [ -n "$(git status --porcelain -- yarn.lock)" ]; then \ | ||||
|     echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \ | ||||
|     git status --porcelain -- yarn.lock; \ | ||||
|     exit 1; \ | ||||
|   fi | ||||
| @@ -31,8 +31,8 @@ | ||||
|     "@actions/core": "^1.2.6", | ||||
|     "@actions/exec": "^1.0.4", | ||||
|     "@actions/github": "^4.0.0", | ||||
|     "csv-parse": "^4.14.1", | ||||
|     "semver": "^7.3.4", | ||||
|     "csv-parse": "^4.15.3", | ||||
|     "semver": "^7.3.5", | ||||
|     "tmp": "^0.2.1" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|   | ||||
| @@ -18,17 +18,34 @@ export async function getImageID(): Promise<string | undefined> { | ||||
|   return fs.readFileSync(iidFile, {encoding: 'utf-8'}); | ||||
| } | ||||
|  | ||||
| export async function getSecret(kvp: string): Promise<string> { | ||||
| export async function getSecretString(kvp: string): Promise<string> { | ||||
|   return getSecret(kvp, false); | ||||
| } | ||||
|  | ||||
| export async function getSecretFile(kvp: string): Promise<string> { | ||||
|   return getSecret(kvp, true); | ||||
| } | ||||
|  | ||||
| export async function getSecret(kvp: string, file: boolean): Promise<string> { | ||||
|   const delimiterIndex = kvp.indexOf('='); | ||||
|   const key = kvp.substring(0, delimiterIndex); | ||||
|   const value = kvp.substring(delimiterIndex + 1); | ||||
|   let value = kvp.substring(delimiterIndex + 1); | ||||
|   if (key.length == 0 || value.length == 0) { | ||||
|     throw new Error(`${kvp} is not a valid secret`); | ||||
|   } | ||||
|  | ||||
|   if (file) { | ||||
|     if (!fs.existsSync(value)) { | ||||
|       throw new Error(`secret file ${value} not found`); | ||||
|     } | ||||
|     value = fs.readFileSync(value, {encoding: 'utf-8'}); | ||||
|   } | ||||
|  | ||||
|   const secretFile = context.tmpNameSync({ | ||||
|     tmpdir: context.tmpDir() | ||||
|   }); | ||||
|   await fs.writeFileSync(secretFile, value); | ||||
|   fs.writeFileSync(secretFile, value); | ||||
|  | ||||
|   return `id=${key},src=${secretFile}`; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -13,30 +13,32 @@ import * as buildx from './buildx'; | ||||
| let _defaultContext, _tmpDir: string; | ||||
|  | ||||
| export interface Inputs { | ||||
|   context: string; | ||||
|   file: string; | ||||
|   buildArgs: string[]; | ||||
|   labels: string[]; | ||||
|   tags: string[]; | ||||
|   pull: boolean; | ||||
|   target: string; | ||||
|   allow: string[]; | ||||
|   noCache: boolean; | ||||
|   buildArgs: string[]; | ||||
|   builder: string; | ||||
|   platforms: string[]; | ||||
|   load: boolean; | ||||
|   push: boolean; | ||||
|   outputs: string[]; | ||||
|   cacheFrom: string[]; | ||||
|   cacheTo: string[]; | ||||
|   context: string; | ||||
|   file: string; | ||||
|   labels: string[]; | ||||
|   load: boolean; | ||||
|   network: string; | ||||
|   noCache: boolean; | ||||
|   outputs: string[]; | ||||
|   platforms: string[]; | ||||
|   pull: boolean; | ||||
|   push: boolean; | ||||
|   secrets: string[]; | ||||
|   githubToken: string; | ||||
|   secretFiles: string[]; | ||||
|   ssh: string[]; | ||||
|   tags: string[]; | ||||
|   target: string; | ||||
|   githubToken: string; | ||||
| } | ||||
|  | ||||
| export function defaultContext(): string { | ||||
|   if (!_defaultContext) { | ||||
|     _defaultContext = `https://github.com/${github.context.repo.owner}/${ | ||||
|     _defaultContext = `${process.env.GITHUB_SERVER_URL || 'https://github.com'}/${github.context.repo.owner}/${ | ||||
|       github.context.repo.repo | ||||
|     }.git#${github.context?.ref?.replace(/^refs\//, '')}`; | ||||
|   } | ||||
| @@ -56,25 +58,27 @@ export function tmpNameSync(options?: tmp.TmpNameOptions): string { | ||||
|  | ||||
| export async function getInputs(defaultContext: string): Promise<Inputs> { | ||||
|   return { | ||||
|     context: core.getInput('context') || defaultContext, | ||||
|     file: core.getInput('file') || 'Dockerfile', | ||||
|     buildArgs: await getInputList('build-args', true), | ||||
|     labels: await getInputList('labels', true), | ||||
|     tags: await getInputList('tags'), | ||||
|     pull: /true/i.test(core.getInput('pull')), | ||||
|     target: core.getInput('target'), | ||||
|     allow: await getInputList('allow'), | ||||
|     noCache: /true/i.test(core.getInput('no-cache')), | ||||
|     buildArgs: await getInputList('build-args', true), | ||||
|     builder: core.getInput('builder'), | ||||
|     platforms: await getInputList('platforms'), | ||||
|     load: /true/i.test(core.getInput('load')), | ||||
|     push: /true/i.test(core.getInput('push')), | ||||
|     outputs: await getInputList('outputs', true), | ||||
|     cacheFrom: await getInputList('cache-from', true), | ||||
|     cacheTo: await getInputList('cache-to', true), | ||||
|     context: core.getInput('context') || defaultContext, | ||||
|     file: core.getInput('file'), | ||||
|     labels: await getInputList('labels', true), | ||||
|     load: /true/i.test(core.getInput('load')), | ||||
|     network: core.getInput('network'), | ||||
|     noCache: /true/i.test(core.getInput('no-cache')), | ||||
|     outputs: await getInputList('outputs', true), | ||||
|     platforms: await getInputList('platforms'), | ||||
|     pull: /true/i.test(core.getInput('pull')), | ||||
|     push: /true/i.test(core.getInput('push')), | ||||
|     secrets: await getInputList('secrets', true), | ||||
|     githubToken: core.getInput('github-token'), | ||||
|     ssh: await getInputList('ssh') | ||||
|     secretFiles: await getInputList('secret-files', true), | ||||
|     ssh: await getInputList('ssh'), | ||||
|     tags: await getInputList('tags'), | ||||
|     target: core.getInput('target'), | ||||
|     githubToken: core.getInput('github-token') | ||||
|   }; | ||||
| } | ||||
|  | ||||
| @@ -123,13 +127,20 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio | ||||
|   }); | ||||
|   await asyncForEach(inputs.secrets, async secret => { | ||||
|     try { | ||||
|       args.push('--secret', await buildx.getSecret(secret)); | ||||
|       args.push('--secret', await buildx.getSecretString(secret)); | ||||
|     } catch (err) { | ||||
|       core.warning(err.message); | ||||
|     } | ||||
|   }); | ||||
|   await asyncForEach(inputs.secretFiles, async secretFile => { | ||||
|     try { | ||||
|       args.push('--secret', await buildx.getSecretFile(secretFile)); | ||||
|     } catch (err) { | ||||
|       core.warning(err.message); | ||||
|     } | ||||
|   }); | ||||
|   if (inputs.githubToken && !buildx.hasGitAuthToken(inputs.secrets) && inputs.context == defaultContext) { | ||||
|     args.push('--secret', await buildx.getSecret(`GIT_AUTH_TOKEN=${inputs.githubToken}`)); | ||||
|     args.push('--secret', await buildx.getSecretString(`GIT_AUTH_TOKEN=${inputs.githubToken}`)); | ||||
|   } | ||||
|   await asyncForEach(inputs.ssh, async ssh => { | ||||
|     args.push('--ssh', ssh); | ||||
| @@ -154,6 +165,9 @@ async function getCommonArgs(inputs: Inputs): Promise<Array<string>> { | ||||
|   if (inputs.load) { | ||||
|     args.push('--load'); | ||||
|   } | ||||
|   if (inputs.network) { | ||||
|     args.push('--network', inputs.network); | ||||
|   } | ||||
|   if (inputs.push) { | ||||
|     args.push('--push'); | ||||
|   } | ||||
|   | ||||
							
								
								
									
										22
									
								
								yarn.lock
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								yarn.lock
									
									
									
									
									
								
							| @@ -1236,10 +1236,10 @@ cssstyle@^2.2.0: | ||||
|   dependencies: | ||||
|     cssom "~0.3.6" | ||||
|  | ||||
| csv-parse@*, csv-parse@^4.14.1: | ||||
|   version "4.14.1" | ||||
|   resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-4.14.1.tgz#b6b3736508fb94682fa6d450fe1755237221d291" | ||||
|   integrity sha512-4wmcO7QbWtDAncGFaBwlWFPhEN4Akr64IbM4zvDwEOFekI8blLc04Nw7XjQjtSNy+3AUAgBgtUa9nWo5Cq89Xg== | ||||
| csv-parse@*, csv-parse@^4.15.3: | ||||
|   version "4.15.3" | ||||
|   resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-4.15.3.tgz#8a62759617a920c328cb31c351b05053b8f92b10" | ||||
|   integrity sha512-jlTqDvLdHnYMSr08ynNfk4IAUSJgJjTKy2U5CQBSu4cN9vQOJonLVZP4Qo4gKKrIgIQ5dr07UwOJdi+lRqT12w== | ||||
|  | ||||
| dashdash@^1.12.0: | ||||
|   version "1.14.1" | ||||
| @@ -3243,10 +3243,10 @@ saxes@^5.0.0: | ||||
|   resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" | ||||
|   integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== | ||||
|  | ||||
| semver@7.x, semver@^7.3.2, semver@^7.3.4: | ||||
|   version "7.3.4" | ||||
|   resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97" | ||||
|   integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw== | ||||
| semver@7.x, semver@^7.3.2, semver@^7.3.5: | ||||
|   version "7.3.5" | ||||
|   resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" | ||||
|   integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== | ||||
|   dependencies: | ||||
|     lru-cache "^6.0.0" | ||||
|  | ||||
| @@ -3895,9 +3895,9 @@ xmlchars@^2.2.0: | ||||
|   integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== | ||||
|  | ||||
| y18n@^4.0.0: | ||||
|   version "4.0.0" | ||||
|   resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" | ||||
|   integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== | ||||
|   version "4.0.1" | ||||
|   resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4" | ||||
|   integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ== | ||||
|  | ||||
| yallist@^2.1.2: | ||||
|   version "2.1.2" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user