1
+ name : Build and Publish Docker Image
2
+
3
+ on :
4
+ push :
5
+ pull_request :
6
+ workflow_dispatch :
7
+
8
+ env :
9
+ REGISTRY : ghcr.io
10
+ IMAGE_NAME : ${{ github.repository }}
11
+
12
+ jobs :
13
+ build-publish :
14
+ env :
15
+ SHOULD_PUSH_IMAGE : ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev')) || github.event_name == 'workflow_dispatch' }}
16
+ runs-on : ubuntu-latest
17
+
18
+ permissions :
19
+ contents : read
20
+ packages : write
21
+
22
+ steps :
23
+ - name : Set up QEMU for Docker
24
+ uses : docker/setup-qemu-action@v3
25
+
26
+ - name : Set up Docker Buildx
27
+ uses : docker/setup-buildx-action@v3
28
+
29
+ - name : Log into the container registry
30
+ if : ${{ env.SHOULD_PUSH_IMAGE == 'true' }}
31
+ uses : docker/login-action@v3
32
+ with :
33
+ registry : ${{ env.REGISTRY }}
34
+ username : ${{ github.actor }}
35
+ password : ${{ secrets.GITHUB_TOKEN }}
36
+
37
+ - name : Extract Docker metadata
38
+ id : meta
39
+ uses : docker/metadata-action@v5
40
+ with :
41
+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
42
+ tags : |
43
+ type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
44
+ type=raw,value=edge,enable=${{ github.ref == 'refs/heads/dev' }}
45
+ type=sha
46
+
47
+ - name : Build and push Docker image
48
+ id : build-and-push
49
+ uses : docker/build-push-action@v6
50
+ with :
51
+ platforms : linux/amd64,linux/arm64
52
+ push : ${{ env.SHOULD_PUSH_IMAGE }}
53
+ tags : ${{ steps.meta.outputs.tags }}
54
+ labels : ${{ steps.meta.outputs.labels }}
55
+ cache-from : type=gha
56
+ cache-to : type=gha,mode=max
0 commit comments