Split push image manifest #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Multi-platform Docker image push to Google Artifact Registry | ||
on: | ||
workflow_call: | ||
inputs: | ||
platforms: | ||
default: "['amd46']" | ||
type: string | ||
image_name: | ||
required: true | ||
type: string | ||
registry: | ||
description: | | ||
Google Artifact Registry to store docker images in. | ||
default: "us-docker.pkg.dev" | ||
type: string | ||
tags: | ||
type: string | ||
description: | | ||
List of Docker images to be pushed. | ||
required: true | ||
context: | ||
description: | | ||
Path to the Docker build context. | ||
default: "." | ||
type: string | ||
environment: | ||
description: | | ||
Environment for pushing artifacts (can be either dev or prod). | ||
default: dev | ||
type: string | ||
build-args: | ||
type: string | ||
description: | | ||
List of arguments necessary for the Docker image to be built. | ||
default: "" | ||
file: | ||
type: string | ||
description: | | ||
The dockerfile to use. | ||
required: false | ||
cache-from: | ||
type: string | ||
description: | | ||
Where cache should be fetched from | ||
required: false | ||
default: "type=gha" | ||
cache-to: | ||
type: string | ||
description: | | ||
Where cache should be stored to | ||
required: false | ||
default: "type=gha,mode=max" | ||
ssh: | ||
type: string | ||
description: | | ||
List of SSH agent socket or keys to expose to the build | ||
permissions: | ||
contents: read | ||
id-token: write | ||
env: | ||
platform_env: ${{ inputs.platforms }} | ||
jobs: | ||
build-multi-arch: | ||
outputs: | ||
full_image_name: ${{ steps.build-multiarch.outputs.full_image_name }} | ||
strategy: | ||
matrix: | ||
os: ${{ fromJson(inputs.platforms ) }} | ||
tags: ${{ fromJson(inputs.tags ) }} | ||
runs-on: ubuntu-${{ matrix.os }}-large | ||
name: build-${{ matrix.os }}-image-for-tag-${{ matrix.tags }} | ||
steps: | ||
- name: Checkout | ||
env: | ||
action_repo: ${{ github.action_repository }} | ||
action_ref: ${{ github.action_ref }} | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
repository: ${{ env.action_repo }} | ||
ref: ${{ env.action_ref }} | ||
- name: Checkout | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
repository: grafana/shared-workflows | ||
ref: multiarch-docker-builds-using-sh-runners | ||
path: shared-workflows | ||
- name: Build multi-arch | ||
id: build-multiarch | ||
uses: ./shared-workflows/actions/push-image-digests | ||
with: | ||
platform: "linux/${{ matrix.os }}" | ||
image_name: ${{ inputs.image_name }} | ||
tags: ${{ matrix.tags }} | ||
context: ${{ inputs.context }} | ||
build-args: ${{ inputs.build-args }} | ||
cache-from: ${{ inputs.cache-from }} | ||
cache-to: ${{ inputs.cache-to }} | ||
file: ${{ inputs.file }} | ||
ssh: ${{ inputs.ssh }} | ||
push-manifest: | ||
strategy: | ||
matrix: | ||
tags: ${{ fromJson(inputs.tags ) }} | ||
needs: [build-multi-arch] | ||
name: push-manifest | ||
runs-on: ubuntu-x64-small | ||
steps: | ||
- name: Checkout | ||
env: | ||
action_repo: ${{ github.action_repository }} | ||
action_ref: ${{ github.action_ref }} | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
repository: ${{ env.action_repo }} | ||
ref: ${{ env.action_ref }} | ||
- name: Checkout | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
repository: grafana/shared-workflows | ||
ref: multiarch-docker-builds-using-sh-runners | ||
path: shared-workflows | ||
- name: Create and push image manifests | ||
uses: ./shared-workflows/actions/create-and-push-image-manifests | ||
with: | ||
<<<<<<< Updated upstream | ||
path: /tmp/digests | ||
pattern: digests-*-${{ matrix.tags }} | ||
merge-multiple: true | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ needs.build-multi-arch.outputs.full_image_name }} | ||
tags: ${{ matrix.tags }} | ||
- uses: grafana/shared-workflows/actions/login-to-gar@main | ||
id: login-to-gar | ||
- name: Create manifest list and push | ||
working-directory: /tmp/digests | ||
run: | | ||
"docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | ||
$(printf '${{ needs.build-multi-arch.outputs.full_image_name }}@sha256:%s ' *)" | ||
- name: Inspect image | ||
run: | | ||
"docker buildx imagetools inspect ${{ needs.build-multi-arch.outputs.full_image_name }}:${{ steps.meta.outputs.version }}" | ||
======= | ||
full-image-name: ${{ needs.build-multi-arch.outputs.full_image_name }} | ||
tag: ${{ matrix.tags }} | ||
>>>>>>> Stashed changes |