File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Docker Image CI
2
+
3
+ on :
4
+ push :
5
+ branches : [ main ]
6
+ pull_request :
7
+ workflow_dispatch :
8
+ inputs :
9
+ branch :
10
+ description : ' Branch to run the workflow on'
11
+ required : false
12
+ tags :
13
+ - " v*.*.*" # Runs on version tags
14
+
15
+
16
+ jobs :
17
+ build-and-push :
18
+ runs-on : ubuntu-latest
19
+ permissions :
20
+ contents : read
21
+ packages : write
22
+
23
+ steps :
24
+ - name : Checkout code
25
+ uses : actions/checkout@v4
26
+ with :
27
+ fetch-depth : 0 # Saves time by not fetching other branches
28
+
29
+ - name : Set up Docker Buildx
30
+ uses : docker/setup-buildx-action@v3
31
+
32
+ - name : Login to GitHub Container Registry
33
+ uses : docker/login-action@v3
34
+ with :
35
+ registry : ghcr.io
36
+ username : ${{ github.repository_owner }}
37
+ password : ${{ secrets.GITHUB_TOKEN }}
38
+
39
+ - name : Build and push Docker image
40
+ id : docker_build
41
+ uses : docker/build-push-action@v6
42
+ with :
43
+ context : .
44
+ push : true
45
+ tags : |
46
+ ghcr.io/${{ github.repository }}:${{ github.ref_name }}
47
+ ${{ github.ref_name == 'main' && format('ghcr.io/{0}:latest', github.repository) || '' }}
48
+ cache-from : type=gha
49
+ cache-to : type=gha,mode=max
You can’t perform that action at this time.
0 commit comments