Skip to content

Commit d010d03

Browse files
committed
Build image when pushing to main.
1 parent 0d3a782 commit d010d03

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/docker.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
name: Docker
33

44
on:
5+
push:
6+
branches: [main]
7+
paths: [Dockerfile]
58
workflow_dispatch:
69
inputs:
710
ref:
@@ -34,11 +37,18 @@ jobs:
3437
uses: docker/setup-buildx-action@v4
3538

3639
- name: Log in to Docker Hub
40+
if: github.event_name != 'push'
3741
uses: docker/login-action@v4
3842
with:
3943
username: ${{ secrets.DOCKERHUB_USERNAME }}
4044
password: ${{ secrets.DOCKERHUB_TOKEN }}
4145

46+
# Build only (no push) to validate the Dockerfile on changes to main.
47+
- name: Setup vars (push)
48+
if: github.event_name == 'push'
49+
run: |
50+
echo "STELLAR_CLI_REF=${{ github.sha }}" >> $GITHUB_ENV
51+
4252
# Use the published tag as the ref; set both the versioned and `latest` tags.
4353
- name: Setup vars (release)
4454
if: github.event_name == 'release'
@@ -78,6 +88,6 @@ jobs:
7888
with:
7989
context: .
8090
platforms: linux/amd64,linux/arm64
81-
push: true
91+
push: ${{ github.event_name != 'push' }}
8292
build-args: STELLAR_CLI_REF=${{ env.STELLAR_CLI_REF }}
8393
tags: ${{ env.DOCKER_TAGS }}

0 commit comments

Comments
 (0)