mirror of https://github.com/docker/docs.git
				
				
				
			Merge pull request #22126 from crazy-max/build-tags-distributed
build: use tags input for distributed builds workflow
This commit is contained in:
		
						commit
						641f973b10
					
				|  | @ -124,8 +124,7 @@ on: | |||
|   push: | ||||
| 
 | ||||
| env: | ||||
|   DOCKERHUB_REPO: docker-user/my-app | ||||
|   GHCR_REPO: ghcr.io/gh-user/my-app | ||||
|   REGISTRY_IMAGE: user/app | ||||
| 
 | ||||
| jobs: | ||||
|   build: | ||||
|  | @ -146,9 +145,7 @@ jobs: | |||
|         id: meta | ||||
|         uses: docker/metadata-action@v5 | ||||
|         with: | ||||
|           images: | | ||||
|             ${{ env.DOCKERHUB_REPO }} | ||||
|             ${{ env.GHCR_REPO }} | ||||
|           images: ${{ env.REGISTRY_IMAGE }} | ||||
| 
 | ||||
|       - name: Login to Docker Hub | ||||
|         uses: docker/login-action@v3 | ||||
|  | @ -156,13 +153,6 @@ jobs: | |||
|           username: ${{ vars.DOCKERHUB_USERNAME }} | ||||
|           password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
| 
 | ||||
|       - name: Login to GHCR | ||||
|         uses: docker/login-action@v3 | ||||
|         with: | ||||
|           registry: ghcr.io | ||||
|           username: ${{ github.repository_owner }} | ||||
|           password: ${{ secrets.GITHUB_TOKEN }} | ||||
| 
 | ||||
|       - name: Set up QEMU | ||||
|         uses: docker/setup-qemu-action@v3 | ||||
| 
 | ||||
|  | @ -175,7 +165,8 @@ jobs: | |||
|         with: | ||||
|           platforms: ${{ matrix.platform }} | ||||
|           labels: ${{ steps.meta.outputs.labels }} | ||||
|           outputs: type=image,"name=${{ env.DOCKERHUB_REPO }},${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true | ||||
|           tags: ${{ env.REGISTRY_IMAGE }} | ||||
|           outputs: type=image,push-by-digest=true,name-canonical=true,push=true | ||||
| 
 | ||||
|       - name: Export digest | ||||
|         run: | | ||||
|  | @ -209,13 +200,6 @@ jobs: | |||
|           username: ${{ vars.DOCKERHUB_USERNAME }} | ||||
|           password: ${{ secrets.DOCKERHUB_TOKEN }} | ||||
| 
 | ||||
|       - name: Login to GHCR | ||||
|         uses: docker/login-action@v3 | ||||
|         with: | ||||
|           registry: ghcr.io | ||||
|           username: ${{ github.repository_owner }} | ||||
|           password: ${{ secrets.GITHUB_TOKEN }} | ||||
| 
 | ||||
|       - name: Set up Docker Buildx | ||||
|         uses: docker/setup-buildx-action@v3 | ||||
| 
 | ||||
|  | @ -223,9 +207,7 @@ jobs: | |||
|         id: meta | ||||
|         uses: docker/metadata-action@v5 | ||||
|         with: | ||||
|           images: | | ||||
|             ${{ env.DOCKERHUB_REPO }} | ||||
|             ${{ env.GHCR_REPO }} | ||||
|           images: ${{ env.REGISTRY_IMAGE }} | ||||
|           tags: | | ||||
|             type=ref,event=branch | ||||
|             type=ref,event=pr | ||||
|  | @ -236,14 +218,11 @@ jobs: | |||
|         working-directory: ${{ runner.temp }}/digests | ||||
|         run: | | ||||
|           docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | ||||
|             $(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *) | ||||
|           docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | ||||
|             $(printf '${{ env.GHCR_REPO }}@sha256:%s ' *) | ||||
|             $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | ||||
| 
 | ||||
|       - name: Inspect image | ||||
|         run: | | ||||
|           docker buildx imagetools inspect ${{ env.DOCKERHUB_REPO }}:${{ steps.meta.outputs.version }} | ||||
|           docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }} | ||||
|           docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | ||||
| ``` | ||||
| 
 | ||||
| ### With Bake | ||||
|  | @ -377,9 +356,9 @@ jobs: | |||
|             cwd://${{ runner.temp }}/bake-meta.json | ||||
|           targets: image | ||||
|           set: | | ||||
|             *.tags= | ||||
|             *.tags=${{ env.REGISTRY_IMAGE }} | ||||
|             *.platform=${{ matrix.platform }} | ||||
|             *.output=type=image,"name=${{ env.REGISTRY_IMAGE }}",push-by-digest=true,name-canonical=true,push=true | ||||
|             *.output=type=image,push-by-digest=true,name-canonical=true,push=true | ||||
| 
 | ||||
|       - name: Export digest | ||||
|         run: | | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue