File tree 1 file changed +15
-14
lines changed
1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change 6
6
pull_request :
7
7
branches : [main]
8
8
9
- env :
10
- IMAGE_NAME : ghtoken_product_demo
11
-
12
9
jobs :
13
10
build_container :
14
11
name : Build Docker image
12
+ if : github.event_name == 'pull_request'
15
13
runs-on : ubuntu-20.04
16
14
steps :
17
- - name : Check out the repo
18
- uses : actions/checkout @v3
19
-
20
- - name : Build Container image
21
- run : docker build . --tag $IMAGE_NAME
15
+ - name : Build the image
16
+ uses : docker/build-push-action @v3
17
+ with :
18
+ context : .
19
+ tags : user/app:latest
22
20
23
21
push_to_registry :
24
22
name : Push Docker image to Github Container Registry
25
23
if : github.event_name == 'release'
26
24
runs-on : ubuntu-20.04
27
25
needs : [build_container]
28
26
steps :
29
- - uses : docker/login-action@v2
27
+ - name : Login to GHCR
28
+ uses : docker/login-action@v2
30
29
with :
31
30
registry : ghcr.io
32
31
username : ${{ github.actor }}
33
32
password : ${{ secrets.GITHUB_TOKEN }}
34
-
35
- - name : Push image to GHCR
36
- run : |
37
- IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:${{ github.run.id }}
38
- docker push $IMAGE_ID
33
+
34
+ - name : Build and push image to GHCR
35
+ uses : docker/build-push-action@v3
36
+ with :
37
+ context : .
38
+ push : true
39
+ tags : user/app:latest
You can’t perform that action at this time.
0 commit comments