Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 104 additions & 26 deletions .github/workflows/_shared-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ on:
required: false
type: boolean
docker_repository:
description: 'Docker Hub Repository'
description: 'Image repository (ghcr.io/ethpandaops/<image>)'
default: ''
required: false
type: string
Expand All @@ -53,11 +53,8 @@ on:
required: false
type: string
secrets:
DOCKERHUB_USERNAME:
description: 'Docker Hub Username'
required: false
DOCKERHUB_TOKEN:
description: 'Docker Hub Token'
IMAGE_MIRROR_URL:
description: 'Image mirror URL (IMAGE_MIRROR_URL organization secret)'
required: false

permissions:
Expand Down Expand Up @@ -274,6 +271,11 @@ jobs:
needs: [build_linux_amd64_binary]
if: ${{ inputs.docker }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
attestations: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
Expand All @@ -286,11 +288,12 @@ jobs:
# prepare docker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: Login to Docker Hub
- name: Login to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

# download build artifacts
- name: Download build artifacts
Expand All @@ -314,15 +317,37 @@ jobs:
--tag ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-amd64 \
--platform=linux/amd64
- name: Push amd64 docker images
id: push
run: |
docker push ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-amd64
docker push ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-amd64
set -o pipefail
docker push ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-amd64 | tee -a "$RUNNER_TEMP/docker-push.log"
docker push ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-amd64 | tee -a "$RUNNER_TEMP/docker-push.log"
# Both tags name the same local image, so docker push reports one digest.
digest=$(grep -oE 'digest: sha256:[a-f0-9]{64}' "$RUNNER_TEMP/docker-push.log" | cut -d' ' -f2 | sort -u)
if [[ ! "$digest" =~ ^sha256:[a-f0-9]{64}$ ]]; then
echo "::error::Expected one pushed digest, got: $digest"
exit 1
fi
echo "digest=$digest" >> "$GITHUB_OUTPUT"
- name: Attest and mirror amd64 docker images to Docker Hub
uses: ethpandaops/actions/mirror-image@738aeadbcdc54f1c9af659d35f8ef29dd5c0fae6
with:
tags: |
${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-amd64
${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-amd64
digest: ${{ steps.push.outputs.digest }}
mirror-url: ${{ secrets.IMAGE_MIRROR_URL }}

build_arm64_docker_image:
name: Build arm64 docker image
needs: [build_linux_arm64_binary]
if: ${{ inputs.docker }}
runs-on: ubuntu-24.04-arm
permissions:
contents: read
packages: write
id-token: write
attestations: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
Expand All @@ -334,11 +359,12 @@ jobs:
# prepare docker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: Login to Docker Hub
- name: Login to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

# download build artifacts
- name: Download build artifacts
Expand All @@ -362,15 +388,37 @@ jobs:
--tag ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-arm64 \
--platform=linux/arm64
- name: Push arm64 docker image
id: push
run: |
docker push ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-arm64
docker push ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-arm64
set -o pipefail
docker push ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-arm64 | tee -a "$RUNNER_TEMP/docker-push.log"
docker push ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-arm64 | tee -a "$RUNNER_TEMP/docker-push.log"
# Both tags name the same local image, so docker push reports one digest.
digest=$(grep -oE 'digest: sha256:[a-f0-9]{64}' "$RUNNER_TEMP/docker-push.log" | cut -d' ' -f2 | sort -u)
if [[ ! "$digest" =~ ^sha256:[a-f0-9]{64}$ ]]; then
echo "::error::Expected one pushed digest, got: $digest"
exit 1
fi
echo "digest=$digest" >> "$GITHUB_OUTPUT"
- name: Attest and mirror arm64 docker images to Docker Hub
uses: ethpandaops/actions/mirror-image@738aeadbcdc54f1c9af659d35f8ef29dd5c0fae6
with:
tags: |
${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-arm64
${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-arm64
digest: ${{ steps.push.outputs.digest }}
mirror-url: ${{ secrets.IMAGE_MIRROR_URL }}

build_multiarch_image:
name: Build multiarch docker image
needs: [build_amd64_docker_image, build_arm64_docker_image]
if: ${{ inputs.docker }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
attestations: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
Expand All @@ -382,24 +430,39 @@ jobs:
# prepare docker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: Login to Docker Hub
- name: Login to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

# build multiarch image
- name: Build multiarch docker manifest
id: manifest
run: |
docker buildx imagetools create -t ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }} \
docker buildx imagetools create --metadata-file "$RUNNER_TEMP/manifest.json" -t ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }} \
${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-amd64 \
${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-arm64
digest=$(jq -er '."containerimage.descriptor".digest' "$RUNNER_TEMP/manifest.json")
echo "digest=$digest" >> "$GITHUB_OUTPUT"
- name: Attest and mirror multiarch docker manifest to Docker Hub
uses: ethpandaops/actions/mirror-image@738aeadbcdc54f1c9af659d35f8ef29dd5c0fae6
with:
tags: ${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}
digest: ${{ steps.manifest.outputs.digest }}
mirror-url: ${{ secrets.IMAGE_MIRROR_URL }}

build_extra_image:
name: Build additional docker manifests
needs: [build_multiarch_image]
if: ${{ inputs.additional_tags }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
attestations: write
strategy:
matrix:
tag: ${{ fromJSON(inputs.additional_tags) }}
Expand All @@ -414,21 +477,36 @@ jobs:
# prepare docker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: Login to Docker Hub
- name: Login to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

# build multiarch image
- name: "Build additional docker manifest: ${{ matrix.tag }}"
id: manifest
run: |
docker buildx imagetools create -t ${{ inputs.docker_repository }}:${{ matrix.tag }}-amd64 \
docker buildx imagetools create --metadata-file "$RUNNER_TEMP/amd64.json" -t ${{ inputs.docker_repository }}:${{ matrix.tag }}-amd64 \
${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-amd64

docker buildx imagetools create -t ${{ inputs.docker_repository }}:${{ matrix.tag }}-arm64 \
docker buildx imagetools create --metadata-file "$RUNNER_TEMP/arm64.json" -t ${{ inputs.docker_repository }}:${{ matrix.tag }}-arm64 \
${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-arm64

docker buildx imagetools create -t ${{ inputs.docker_repository }}:${{ matrix.tag }} \
docker buildx imagetools create --metadata-file "$RUNNER_TEMP/multiarch.json" -t ${{ inputs.docker_repository }}:${{ matrix.tag }} \
${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-amd64 \
${{ inputs.docker_repository }}:${{ inputs.docker_tag_prefix }}-${{ steps.vars.outputs.sha_short }}-arm64

for name in amd64 arm64 multiarch; do
digest=$(jq -er '."containerimage.descriptor".digest' "$RUNNER_TEMP/$name.json")
echo "${name}_digest=$digest" >> "$GITHUB_OUTPUT"
done
- name: "Attest and mirror additional docker manifest to Docker Hub: ${{ matrix.tag }}"
uses: ethpandaops/actions/mirror-image@738aeadbcdc54f1c9af659d35f8ef29dd5c0fae6
with:
tags: |
${{ inputs.docker_repository }}:${{ matrix.tag }}-amd64@${{ steps.manifest.outputs.amd64_digest }}
${{ inputs.docker_repository }}:${{ matrix.tag }}-arm64@${{ steps.manifest.outputs.arm64_digest }}
${{ inputs.docker_repository }}:${{ matrix.tag }}@${{ steps.manifest.outputs.multiarch_digest }}
mirror-url: ${{ secrets.IMAGE_MIRROR_URL }}
14 changes: 9 additions & 5 deletions .github/workflows/build-dev-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
group: docker-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: write
Expand All @@ -20,13 +20,17 @@ jobs:
build_binaries:
name: "Build Assertoor"
needs: [check_source]
permissions:
contents: read
packages: write
id-token: write
attestations: write
uses: ./.github/workflows/_shared-build.yaml
with:
release: "snapshot"
docker: true
docker_repository: "ethpandaops/assertoor"
docker_repository: "ghcr.io/ethpandaops/assertoor"
docker_tag_prefix: "master"
additional_tags: "['master','master-latest','latest']"
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
IMAGE_MIRROR_URL: ${{ secrets.IMAGE_MIRROR_URL }}
32 changes: 28 additions & 4 deletions .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
HAS_DOCKER_IMAGE_LABEL: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'build-docker-image') }}
SAME_REPOSITORY_PR: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }}
MANUAL_DOCKER_TAG: ${{ inputs.docker_tag }}
PR_NUMBER: ${{ github.event.pull_request.number }}
# PR head sha (exact branch HEAD). Read via env to avoid script injection. DO NOT REMOVE.
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
FALLBACK_SHA: ${{ github.sha }}
Expand All @@ -61,6 +62,12 @@ jobs:

manual_tag="$MANUAL_DOCKER_TAG"
if [[ ! -z "$manual_tag" ]]; then
# Manual tags must be valid docker tags and must not take reserved names
# (master/main/latest/pr and their -suffixed tags, or release tags).
if [[ ! "$manual_tag" =~ ^[A-Za-z0-9_][A-Za-z0-9_.-]{0,100}$ || "$manual_tag" =~ ^(master|main|latest|pr)(-|$)|^v[0-9] ]]; then
echo "::error::reserved or invalid docker tag: use letters, digits, _ . - (write / as -), and no master, main, latest or pr prefix or v<digit> start"
exit 1
fi
branch_name="$manual_tag"
run_builds="true"
build_docker="true"
Expand All @@ -76,6 +83,12 @@ jobs:
build_docker="false"
fi

# PR builds are tagged pr-<number>, never with the PR's branch name, which could
# otherwise overwrite any existing tag, such as master or a release.
if [[ -n "$PR_NUMBER" ]]; then
branch_name="pr-$PR_NUMBER"
fi

echo "run_builds=$run_builds" >> $GITHUB_OUTPUT
echo "build_docker=$build_docker" >> $GITHUB_OUTPUT
docker_tag="${branch_name//\//-}"
Expand All @@ -92,25 +105,36 @@ jobs:
name: "Build Assertoor"
needs: [prinfo, check_source]
if: ${{ needs.prinfo.outputs.run_builds == 'true' && needs.prinfo.outputs.build_docker != 'true' }}
# Needed to call _shared-build.yaml at all: GitHub checks its docker jobs'
# permissions against this job's even when they are skipped.
permissions:
contents: read
packages: write
id-token: write
attestations: write
uses: ./.github/workflows/_shared-build.yaml
with:
ref: ${{ needs.prinfo.outputs.commit_ref }} # exact branch HEAD, NOT the PR/base merge. DO NOT REMOVE.
docker: false
docker_repository: "ethpandaops/assertoor"
docker_repository: "ghcr.io/ethpandaops/assertoor"
docker_tag_prefix: ${{needs.prinfo.outputs.docker_tag}}
additional_tags: "['${{needs.prinfo.outputs.docker_tag}}','${{needs.prinfo.outputs.docker_tag}}-latest']"

build_binaries_and_docker:
name: "Build Assertoor and Docker image"
needs: [prinfo, check_source]
if: ${{ needs.prinfo.outputs.run_builds == 'true' && needs.prinfo.outputs.build_docker == 'true' }}
permissions:
contents: read
packages: write
id-token: write
attestations: write
uses: ./.github/workflows/_shared-build.yaml
with:
ref: ${{ needs.prinfo.outputs.commit_ref }} # exact branch HEAD, NOT the PR/base merge. DO NOT REMOVE.
docker: true
docker_repository: "ethpandaops/assertoor"
docker_repository: "ghcr.io/ethpandaops/assertoor"
docker_tag_prefix: ${{needs.prinfo.outputs.docker_tag}}
additional_tags: "['${{needs.prinfo.outputs.docker_tag}}','${{needs.prinfo.outputs.docker_tag}}-latest']"
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
IMAGE_MIRROR_URL: ${{ secrets.IMAGE_MIRROR_URL }}
14 changes: 9 additions & 5 deletions .github/workflows/build-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
group: docker-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

permissions:
contents: write
Expand All @@ -23,16 +23,20 @@ jobs:
build_binaries:
name: "Build Assertoor"
needs: [check_source]
permissions:
contents: read
packages: write
id-token: write
attestations: write
uses: ./.github/workflows/_shared-build.yaml
with:
release: "snapshot"
docker: true
docker_repository: "ethpandaops/assertoor"
docker_repository: "ghcr.io/ethpandaops/assertoor"
docker_tag_prefix: "master"
additional_tags: "['master','master-latest']"
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
IMAGE_MIRROR_URL: ${{ secrets.IMAGE_MIRROR_URL }}

create_snapshot_release:
name: Create snapshot release
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ permissions:
jobs:
build_binaries:
name: "Build Assertoor"
permissions:
contents: read
packages: write
id-token: write
attestations: write
uses: ./.github/workflows/_shared-build.yaml
with:
release: "v${{ inputs.version }}"
docker: true
docker_repository: "ethpandaops/assertoor"
docker_repository: "ghcr.io/ethpandaops/assertoor"
docker_tag_prefix: "v${{ inputs.version }}"
additional_tags: "['v${{ inputs.version }}','latest']"
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
IMAGE_MIRROR_URL: ${{ secrets.IMAGE_MIRROR_URL }}

create_release:
name: Create Release
Expand Down
Loading