Skip to content

Commit 2b6bec1

Browse files
author
Luis Corales
committed
update to use docker actions templates
1 parent 443552b commit 2b6bec1

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

.github/workflows/publish-image-ghcr.yml

+15-14
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,34 @@ on:
66
pull_request:
77
branches: [main]
88

9-
env:
10-
IMAGE_NAME: ghtoken_product_demo
11-
129
jobs:
1310
build_container:
1411
name: Build Docker image
12+
if: github.event_name == 'pull_request'
1513
runs-on: ubuntu-20.04
1614
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
2220

2321
push_to_registry:
2422
name: Push Docker image to Github Container Registry
2523
if: github.event_name == 'release'
2624
runs-on: ubuntu-20.04
2725
needs: [build_container]
2826
steps:
29-
- uses: docker/login-action@v2
27+
- name: Login to GHCR
28+
uses: docker/login-action@v2
3029
with:
3130
registry: ghcr.io
3231
username: ${{ github.actor }}
3332
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

0 commit comments

Comments
 (0)