feat(TU-10158): build multi-arch images #1
Workflow file for this run
This file contains 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: Build & push multi-arch image | ||
on: | ||
workflow_call: | ||
secrets: | ||
GITHUB_TOKEN: | ||
description: "GitHub token to download dependencies" | ||
required: true | ||
ECR_REGISTRY: | ||
description: "Image repository" | ||
required: true | ||
inputs: | ||
service: | ||
description: "A name to tag the image" | ||
type: string | ||
required: true | ||
build-args: | ||
description: "Build args" | ||
type: "string" | ||
required: false | ||
context: | ||
description: "Build context" | ||
type: string | ||
required: false | ||
default: "." | ||
labels: | ||
description: "Image labels" | ||
type: string | ||
required: false | ||
default: | | ||
com.typeform.service=${{ inputs.service }} | ||
com.typeform.${{ inputs.service }}.version=${{ github.run_id }} | ||
com.typeform.${{ inputs.service }}.git_commit=${{ github.sha }} | ||
jobs: | ||
build: | ||
name: Build and push image | ||
runs-on: [ self-hosted, bear-ephemeral ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker context for Buildx | ||
run: docker context create builders | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
endpoint: builders | ||
- name: Build and push images | ||
uses: docker/build-push-action@v5 | ||
with: | ||
build-args: ${{ inputs.build-args }} | ||
context: ${{ inputs.context }} | ||
labels: ${{ inputs.labels }} | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ secrets.ECR_REGISTRY }}/${{ inputs.service }}:${{ github.run_id }} | ||
secrets: | | ||
"github_token=${{ secrets.GITHUB_TOKEN }}" | ||
- name: Push latest image | ||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
uses: docker/build-push-action@v5 | ||
with: | ||
build-args: ${{ inputs.build-args }} | ||
context: ${{ inputs.context }} | ||
labels: ${{ inputs.labels }} | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
secrets: | | ||
"github_token=${{ secrets.GITHUB_TOKEN }}" | ||
tags: ${{ secrets.ECR_REGISTRY }}/${{ inputs.service }}:latest |