-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (36 loc) · 1.41 KB
/
docker-build-and-push.yml
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
name: Docker build and push
on:
push:
branches:
- 'main'
env:
IMAGE_NAME: larmic/golang-starter-example
# cancel jobs in current pr if new commit is done
concurrency:
group: `${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}`
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up version # will be read by Dockerfile to set version in open-api-3.yaml
run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: prepare buildx
run: |
# Use docker-container driver to allow useful features (push/multi-platform)
docker buildx create --driver docker-container --use
docker buildx inspect --bootstrap
- name: build image
run: |
update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel
docker buildx build --platform=linux/amd64,linux/arm64,linux/arm --build-arg VERSION=$VERSION --pull --tag "$IMAGE_NAME:$VERSION" --tag "$IMAGE_NAME:latest" . --push