Skip to content

Commit

Permalink
ci: build images reuse workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
huancheng-trili committed Jan 24, 2025
1 parent ded286e commit cd370b4
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 95 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/docker-multiplatform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Build multiplatform docker image

on:
workflow_call:
inputs:
octez-tag:
description: "tezos/tezos docker tag to be used"
required: true
type: string
docker_registry:
description: Docker registry
required: true
type: string
docker_image_base:
description: Docker image base
required: true
type: string
image:
description: Image
required: true
type: string
dockerfile:
description: Dockerfile
required: true
type: string
kernel_artifact_name:
description: Kernel artifact name
required: true
type: string
outputs:
tag:
description: "docker image tag"
value: ${{ jobs.merge.outputs.tag }}

jobs:
build-docker-arm64:
name: Build (Docker arm64)
runs-on: ubuntu-24.04-arm
permissions:
contents: read
packages: write
steps:
- name: Build
uses: jstz-dev/jstz/.github/actions/build-docker-image@huanchengchang-jstz-286
with:
platform: linux
arch: arm64
repo_token: ${{ secrets.GITHUB_TOKEN }}
octez-tag: ${{ inputs.octez-tag }}
docker_registry: ${{ inputs.docker_registry }}
docker_registry_username: ${{ github.actor }}
docker_registry_password: ${{ secrets.GITHUB_TOKEN }}
docker_image_base: ${{ inputs.docker_image_base }}
image: ${{ inputs.image }}
dockerfile: ${{ inputs.dockerfile }}
kernel_artefact_name: ${{ inputs.kernel_artifact_name }}
build-docker-amd64:
name: Build (Docker amd64)
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- name: Build
uses: jstz-dev/jstz/.github/actions/build-docker-image@huanchengchang-jstz-286
with:
platform: linux
arch: amd64
repo_token: ${{ secrets.GITHUB_TOKEN }}
octez-tag: ${{ inputs.octez-tag }}
docker_registry: ${{ inputs.docker_registry }}
docker_registry_username: ${{ github.actor }}
docker_registry_password: ${{ secrets.GITHUB_TOKEN }}
docker_image_base: ${{ inputs.docker_image_base }}
image: ${{ inputs.image }}
dockerfile: ${{ inputs.dockerfile }}
kernel_artefact_name: ${{ inputs.kernel_artifact_name }}
merge:
runs-on: ubuntu-latest
needs:
- build-docker-amd64
- build-docker-arm64
outputs:
tag: ${{ fromJson(steps.meta.outputs.json).tags[0] }}
steps:
- uses: actions/checkout@v4
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests/${{ inputs.image }}
pattern: digests-${{ inputs.image }}-*
merge-multiple: true
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ inputs.docker_registry }}/${{ inputs.docker_image_base }}/${{ inputs.image }}
tags: |
type=ref,event=tag
type=sha
type=raw,value=test-{{sha}}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests/${{ inputs.image }}
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< '${{ steps.meta.outputs.json }}') \
$(printf '${{ inputs.docker_registry }}/${{ inputs.docker_image_base }}/${{ inputs.image }}@sha256:%s ' *)
- name: Inspect image
id: inspect-image
run: |
docker buildx imagetools inspect "${{ fromJson(steps.meta.outputs.json).tags[0] }}"
116 changes: 21 additions & 95 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,16 @@ on:
outputs:
jstz-cli:
description: "jstz docker image tag"
value: ${{ jobs.build-docker.outputs.jstz-cli }}
value: ${{ jobs.build-image.outputs.tag }}
jstz-rollup:
description: "jstz-rollup docker image tag"
value: ${{ jobs.build-docker.outputs.jstz-rollup }}
value: ${{ jobs.build-image.outputs.tag }}
jstz-node:
description: "jstz-node docker image tag"
value: ${{ jobs.build-docker.outputs.jstz-node }}
value: ${{ jobs.build-image.outputs.tag }}
jstzd:
description: "jstzd docker image tag"
value: ${{ jobs.build-docker.outputs.jstzd }}

env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_BASE: jstz-dev/jstz
value: ${{ jobs.build-image.outputs.tag }}

jobs:
build-kernel:
Expand All @@ -56,96 +52,26 @@ jobs:
with:
name: jstz-kernel
path: result/lib/jstz_kernel.wasm

build-docker-arm64:
name: Build (Docker arm64)
needs: [build-kernel]
runs-on: ubuntu-24.04-arm
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- image: jstz-rollup
dockerfile: ./crates/jstz_rollup/Dockerfile
steps:
- uses: jstz-dev/jstz/.github/actions/build-docker-image@huanchengchang-jstz-286
with:
platform: linux
arch: arm64
repo_token: ${{ secrets.GITHUB_TOKEN }}
octez-tag: ${{ inputs.octez-tag }}
docker_registry: ${{ env.DOCKER_REGISTRY }}
docker_registry_username: ${{ github.actor }}
docker_registry_password: ${{ secrets.GITHUB_TOKEN }}
docker_image_base: ${{ env.DOCKER_IMAGE_BASE }}
image: ${{ matrix.image }}
dockerfile: ${{ matrix.dockerfile }}
kernel_artefact_name: jstz-kernel
build-docker-amd64:
name: Build (Docker amd64)
build-image:
name: Build image
needs: [build-kernel]
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- image: jstz-rollup
dockerfile: ./crates/jstz_rollup/Dockerfile
steps:
- uses: jstz-dev/jstz/.github/actions/build-docker-image@huanchengchang-jstz-286
with:
platform: linux
arch: amd64
repo_token: ${{ secrets.GITHUB_TOKEN }}
octez-tag: ${{ inputs.octez-tag }}
docker_registry: ${{ env.DOCKER_REGISTRY }}
docker_registry_username: ${{ github.actor }}
docker_registry_password: ${{ secrets.GITHUB_TOKEN }}
docker_image_base: ${{ env.DOCKER_IMAGE_BASE }}
image: ${{ matrix.image }}
dockerfile: ${{ matrix.dockerfile }}
kernel_artefact_name: jstz-kernel
merge:
runs-on: ubuntu-latest
needs:
- build-docker-amd64
- build-docker-arm64
strategy:
matrix:
include:
- image: jstz-rollup
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests/${{ matrix.image }}
pattern: digests-${{ matrix.image }}-*
merge-multiple: true
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/${{ matrix.image }}
tags: |
type=ref,event=tag
{{sha}}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests/${{ matrix.image }}
run: |
docker buildx imagetools create -t ${{ fromJson(steps.meta.outputs.json).tags[0] }} \
$(printf '${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/${{ matrix.image }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ fromJson(steps.meta.outputs.json).tags[0] }}
- image: jstzd
dockerfile: ./crates/jstzd/Dockerfile
- image: jstz-cli
dockerfile: ./crates/jstz_cli/Dockerfile
- image: jstz-node
dockerfile: ./crates/jstz_node/Dockerfile
uses: jstz-dev/jstz/.github/workflows/docker-multiplatform.yml@huanchengchang-jstz-286
with:
octez-tag: ${{ inputs.octez-tag }}
docker_registry: ghcr.io
docker_image_base: jstz-dev/jstz
image: ${{ matrix.image }}
dockerfile: ${{ matrix.dockerfile }}
kernel_artifact_name: jstz-kernel
secrets: inherit

0 comments on commit cd370b4

Please sign in to comment.