-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (57 loc) · 1.99 KB
/
build-docker.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: container-images
on:
workflow_dispatch:
push:
branches: [ "main" ]
tags: [ "v*" ]
jobs:
build-container-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- run: echo "IMAGE_TAG=main" >> $GITHUB_ENV
if: github.ref_name == 'main'
- run: echo "IMAGE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# TODO:(matej) upload images to dockerhub?
# - name: Login to docker.io
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKER_HUB_UID }}
# password: ${{ secrets.DOCKER_HUB_PAT }}
- name: Build and push image for tags
uses: docker/build-push-action@v6
if: startsWith(github.ref, 'refs/tags/v')
with:
context: . # Because GH actions are for kids and put protection on everything; https://stackoverflow.com/a/71159809/11276254
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
ghcr.io/${{ github.repository }}:latest
# ${{ secrets.DOCKER_HUB_REPO }}:${{ env.IMAGE_TAG }}
# ${{ secrets.DOCKER_HUB_REPO }}:latest
- name: Build and push image for main
uses: docker/build-push-action@v6
if: github.ref_name == 'main'
with:
context: . # Because GH actions are for kids and put protection on everything; https://stackoverflow.com/a/71159809/11276254
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}