File tree 1 file changed +23
-20
lines changed
1 file changed +23
-20
lines changed Original file line number Diff line number Diff line change 6
6
pull_request :
7
7
branches : [main]
8
8
9
- jobs :
10
- build_container :
11
- name : Build Docker image
12
- if : github.event_name == 'pull_request'
9
+ jobs :
10
+ build_docker :
11
+ name : Build and push Docker image to Github Container Registry
13
12
runs-on : ubuntu-20.04
13
+ permissions :
14
+ packages : write
15
+ contents : read
14
16
steps :
15
- - name : Build the image
16
- uses : docker/build-push-action@v3
17
- with :
18
- context : .
19
- tags : user/app:latest
20
-
21
- push_to_registry :
22
- name : Push Docker image to Github Container Registry
23
- if : github.event_name == 'release'
24
- runs-on : ubuntu-20.04
25
- needs : [build_container]
26
- steps :
17
+ - name : Checkout project
18
+ uses : actions/checkout@v3
19
+
20
+ - name : Set up Docker Buildx
21
+ uses : docker/setup-buildx-action@v2
22
+
27
23
- name : Login to GHCR
28
24
uses : docker/login-action@v2
29
25
with :
30
26
registry : ghcr.io
31
27
username : ${{ github.actor }}
32
28
password : ${{ secrets.GITHUB_TOKEN }}
33
-
34
- - name : Build and push image to GHCR
29
+
30
+ - name : Extract metadata (tags, labels) for Docker
31
+ id : meta
32
+
33
+ with :
34
+ images : ghcr.io/${{ github.repository }}
35
+
36
+ - name : Build and push (if release) image to GHCR
35
37
uses : docker/build-push-action@v3
36
38
with :
37
39
context : .
38
- push : true
39
- tags : user/app:latest
40
+ push : ${{ github.event_name == 'release' }}
41
+ tags : ${{ steps.meta.outputs.tags }}
42
+ labels : ${{ steps.meta.outputs.labels }}
You can’t perform that action at this time.
0 commit comments