Skip to content

Commit 4feb79a

Browse files
committed
Update logic
1 parent 1a699b7 commit 4feb79a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

.github/workflows/docker-build-push.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- "v*.*.*" # Triggers on tag push for versioned tags (e.g., v1.0.0)
99

1010
jobs:
11-
build:
11+
build-and-push:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout code
@@ -17,13 +17,14 @@ jobs:
1717
- name: Set up Docker Buildx
1818
uses: docker/setup-buildx-action@v2
1919

20-
- name: Log in to Quay.io
20+
- name: Log in to Quay.io (only if pushing)
21+
if: startsWith(github.ref, 'refs/tags/')
2122
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login quay.io -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
2223

2324
- name: Get tag or commit SHA
2425
id: vars
2526
run: |
26-
if [ "${{ github.event_name }}" = "push" ] && [ -n "${{ github.ref_name }}" ]; then
27+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
2728
echo "image_tag=${{ github.ref_name }}" >> $GITHUB_ENV
2829
else
2930
echo "image_tag=${{ github.sha }}" >> $GITHUB_ENV
@@ -32,8 +33,10 @@ jobs:
3233
- name: Build Docker Image
3334
run: make build
3435

35-
- name: Tag Docker Image
36+
- name: Tag Docker Image (only if pushing)
37+
if: startsWith(github.ref, 'refs/tags/')
3638
run: docker tag fleet-telemetry-consumer quay.io/rajsinghcpre/fleet-telemetry-consumer:${{ env.image_tag }}
3739

38-
- name: Push Docker Image
40+
- name: Push Docker Image (only if pushing)
41+
if: startsWith(github.ref, 'refs/tags/')
3942
run: docker push quay.io/rajsinghcpre/fleet-telemetry-consumer:${{ env.image_tag }}

0 commit comments

Comments
 (0)