Skip to content

Commit b13d7a9

Browse files
committed
testing the 'Build and push Docker image' build step
1 parent ce02cb5 commit b13d7a9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ jobs:
192192
build-and-publish-docker-image: # job to build the docker image and publish it to the GitHub Container Registry
193193
runs-on: ubuntu-latest # using the latest ubuntu runner
194194
needs: [build, uat-parallel-tests] # this job needs build and uat-parallel-tests jobs as a requirement to run
195+
if: github.ref == 'refs/heads/main' # run this job only when the branch is main branch and not on pull requests or other branches - https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
195196
# permissions for write acces to the packages and id-token and push access to the repository to create the container registry token
196197
permissions:
197198
packages: write
@@ -228,9 +229,12 @@ jobs:
228229
registry: ${{ env.REGISTRY }} # using the registry environment variable
229230
username: ${{ github.actor }} # using the github.actor context
230231
password: ${{ secrets.GITHUB_TOKEN }} # using the GITHUB_TOKEN secret
231-
- name: Docker push # push the docker image to the GitHub Container Registry
232-
run: |
233-
docker push ghcr.io/octodemo/${{ github.repository }}:${{ github.run_number }}
232+
- name: Build and push Docker image
233+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
234+
with:
235+
context: . # using the current directory as the context
236+
push: true # push the docker image to the registry
237+
tags: ghcr.io/octodemo/${{ github.repository }}:${{ github.run_number }} # tag the docker image with the current run number from the github action workflow run
234238

235239
runner-indexes: # job to generate the runner indexes for the uat-parallel-tests job
236240
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)