Nyk Ankit Rana commited on
Commit
979f9f9
·
1 Parent(s): a8f371f

feat(ci): publish docker images to ghcr

Browse files

Co-authored-by: Ankit Rana <10462932+arana198@users.noreply.github.com>

.github/workflows/docker-publish.yml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Docker Publish
2
+
3
+ on:
4
+ workflow_run:
5
+ workflows: ['Quality Gate']
6
+ branches: [main]
7
+ types: [completed]
8
+ push:
9
+ tags:
10
+ - 'v*.*.*'
11
+ workflow_dispatch:
12
+
13
+ concurrency:
14
+ group: docker-publish-${{ github.ref }}
15
+ cancel-in-progress: false
16
+
17
+ permissions:
18
+ contents: read
19
+ packages: write
20
+ id-token: write
21
+
22
+ env:
23
+ REGISTRY: ghcr.io
24
+ IMAGE_NAME: ${{ github.repository }}
25
+
26
+ jobs:
27
+ publish:
28
+ if: >
29
+ github.event_name == 'workflow_dispatch' ||
30
+ github.event_name == 'push' ||
31
+ (
32
+ github.event_name == 'workflow_run' &&
33
+ github.event.workflow_run.conclusion == 'success'
34
+ )
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - name: Checkout
38
+ uses: actions/checkout@v4
39
+ with:
40
+ ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}
41
+
42
+ - name: Set up QEMU
43
+ uses: docker/setup-qemu-action@v3
44
+
45
+ - name: Set up Docker Buildx
46
+ uses: docker/setup-buildx-action@v3
47
+
48
+ - name: Log in to GHCR
49
+ uses: docker/login-action@v3
50
+ with:
51
+ registry: ${{ env.REGISTRY }}
52
+ username: ${{ github.actor }}
53
+ password: ${{ secrets.GITHUB_TOKEN }}
54
+
55
+ - name: Docker metadata
56
+ id: meta
57
+ uses: docker/metadata-action@v5
58
+ with:
59
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
60
+ tags: |
61
+ type=sha,prefix=sha-
62
+ type=ref,event=branch
63
+ type=ref,event=tag
64
+ type=semver,pattern={{version}}
65
+ type=semver,pattern={{major}}.{{minor}}
66
+ type=raw,value=latest,enable={{is_default_branch}}
67
+
68
+ - name: Build and push image
69
+ uses: docker/build-push-action@v6
70
+ with:
71
+ context: .
72
+ file: ./Dockerfile
73
+ push: true
74
+ platforms: linux/amd64,linux/arm64
75
+ tags: ${{ steps.meta.outputs.tags }}
76
+ labels: ${{ steps.meta.outputs.labels }}
77
+ cache-from: type=gha
78
+ cache-to: type=gha,mode=max
79
+ provenance: true
80
+ sbom: true