-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (85 loc) · 3.07 KB
/
publish-docker-image.yml
File metadata and controls
102 lines (85 loc) · 3.07 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
name: Build and push Docker images for all components
on:
push:
branches: [ "main" ]
paths:
- package.json
- src/**
pull_request:
branches: [ "main" ]
paths:
- package.json
- src/**
workflow_dispatch: {}
env:
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
IMAGE_NAME: eclipseaerios/benchmarking-tool
jobs:
build-and-push-all:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ env.DOCKER_HUB_USER }}
password: ${{ env.DOCKER_HUB_TOKEN }}
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Get version from package.json
id: get_version
run: echo "VERSION=$(jq -r .version package.json)" >> "$GITHUB_OUTPUT"
- name: Set short SHA
id: shortsha
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
- name: Build and push the container image for AMD64
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64
tags: |
${{ env.IMAGE_NAME }}:latest-amd64
${{ env.IMAGE_NAME }}:${{ steps.get_version.outputs.VERSION }}-amd64
${{ env.IMAGE_NAME }}:${{ steps.shortsha.outputs.SHORT_SHA }}-amd64
- name: Build and push the container image for ARM64
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile-arm64
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/arm64
tags: |
${{ env.IMAGE_NAME }}:latest-arm64
${{ env.IMAGE_NAME }}:${{ steps.get_version.outputs.VERSION }}-arm64
${{ env.IMAGE_NAME }}:${{ steps.shortsha.outputs.SHORT_SHA }}-arm64
- name: Create and push multi-arch manifests (latest, sha, version)
if: ${{ github.event_name != 'pull_request' }}
run: |
image="${{ env.IMAGE_NAME }}"
# latest
docker buildx imagetools create \
-t "$image:latest" \
"$image:latest-amd64" \
"$image:latest-arm64"
# short SHA
docker buildx imagetools create \
-t "$image:${{ steps.shortsha.outputs.SHORT_SHA }}" \
"$image:${{ steps.shortsha.outputs.SHORT_SHA }}-amd64" \
"$image:${{ steps.shortsha.outputs.SHORT_SHA }}-arm64"
# version
docker buildx imagetools create \
-t "$image:${{ steps.get_version.outputs.VERSION }}" \
"$image:${{ steps.get_version.outputs.VERSION }}-amd64" \
"$image:${{ steps.get_version.outputs.VERSION }}-arm64"
# verify
docker buildx imagetools inspect "$image:${{ steps.get_version.outputs.VERSION }}"