-
Notifications
You must be signed in to change notification settings - Fork 81
105 lines (93 loc) · 3.42 KB
/
Copy pathdocker.yml
File metadata and controls
105 lines (93 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Build Docker Image
on:
workflow_dispatch:
inputs:
tag:
description: "The tag of the image to build"
required: true
type: string
is_latest:
description: "Push as latest?"
required: false
default: false
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
ORG: cometbft
IMAGE_NAME: cometbft-db-testing
GIT_TAG: "${{ inputs.tag }}"
jobs:
build-image-at-tag:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
platform: linux/amd64
arch: amd64
- os: ubuntu-24.04-arm
platform: linux/arm64
arch: arm64
runs-on: ${{ matrix.os }}
outputs:
digest_amd64: ${{ steps.capture-digest.outputs.digest_amd64 }}
digest_arm64: ${{ steps.capture-digest.outputs.digest_arm64 }}
steps:
- uses: actions/checkout@v6
with:
ref: "${{ env.GIT_TAG }}"
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push image
id: build
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.platform }}
file: ./tools/Dockerfile
tags: |
${{ env.ORG }}/${{ env.IMAGE_NAME }}:${{ env.GIT_TAG }}
push: true
outputs: type=image,name=${{ env.ORG }}/${{ env.IMAGE_NAME }},digest=true
- name: Capture Image Digest
id: capture-digest
run: |
echo "digest_${{ matrix.arch }}=${{ steps.build.outputs.digest }}" >> $GITHUB_ENV
echo "::set-output name=digest_${{ matrix.arch }}::${{ steps.build.outputs.digest }}"
merge:
runs-on: ubuntu-latest
needs: build-image-at-tag
steps:
- name: Get sanitized Docker tag
run: echo "DOCKER_TAG=$(echo $GIT_TAG | sed 's/[^a-zA-Z0-9\.]/-/g')" >> $GITHUB_ENV
- name: Debug Output Digests
run: |
echo "AMD64 Digest: ${{ needs.build-image-at-tag.outputs.digest_amd64 }}"
echo "ARM64 Digest: ${{ needs.build-image-at-tag.outputs.digest_arm64 }}"
- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create Multi-Arch Manifest
run: |
docker buildx imagetools create \
--tag ${{ env.ORG }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }} \
${{ env.ORG }}/${{ env.IMAGE_NAME }}@${{ needs.build-image-at-tag.outputs.digest_amd64 }} \
${{ env.ORG }}/${{ env.IMAGE_NAME }}@${{ needs.build-image-at-tag.outputs.digest_arm64 }}
- name: Tag and Push Latest (if applicable)
if: ${{ inputs.is_latest == true }}
run: |
docker buildx imagetools create \
--tag ${{ env.ORG }}/${{ env.IMAGE_NAME }}:latest \
${{ env.ORG }}/${{ env.IMAGE_NAME }}@${{ needs.build-image-at-tag.outputs.digest_amd64 }} \
${{ env.ORG }}/${{ env.IMAGE_NAME }}@${{ needs.build-image-at-tag.outputs.digest_arm64 }}