Skip to content

Commit f4ce569

Browse files
GenPageijames-gc
authored andcommitted
fix(ci): only push docker dev tag on main (runatlantis#3393)
- Disables pushing a dev tag within an unmerged pr commit event. - Also disabled pushing at all unless the event comes from the main branch
1 parent aa714b4 commit f4ce569

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

.github/workflows/atlantis-image.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
env:
3232
# Set docker repo to either the fork or the main repo where the branch exists
3333
DOCKER_REPO: ghcr.io/${{ github.repository }}
34-
# Push if not a pull request or this is a fork
35-
PUSH: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}
34+
# Push if not a pull request and references the main branch
35+
PUSH: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
3636

3737
steps:
3838
- uses: actions/checkout@v3
@@ -75,9 +75,9 @@ jobs:
7575
type=semver,pattern={{version}},prefix=v,enable=${{ matrix.image_type == 'alpine' }}
7676
type=semver,pattern={{major}}.{{minor}},prefix=v,suffix=${{ env.SUFFIX }}
7777
# dev
78-
type=raw,value=dev,suffix=${{ env.SUFFIX }}-{{ sha }}
79-
type=raw,event=push,value=dev,enable=${{ github.ref == format('refs/heads/{0}', 'main') && matrix.image_type == 'alpine' }},suffix=
8078
type=raw,event=push,value=dev,enable={{is_default_branch}},suffix=${{ env.SUFFIX }}
79+
type=raw,event=push,value=dev,enable={{is_default_branch}},suffix=${{ env.SUFFIX }}-{{ sha }}
80+
type=raw,event=push,value=dev,enable=${{ github.ref == format('refs/heads/{0}', 'main') && matrix.image_type == 'alpine' }},suffix=
8181
# prerelease
8282
type=raw,event=tag,value=prerelease-latest,enable=${{ startsWith(github.ref, 'refs/tags/') && contains(github.ref, 'pre') && matrix.image_type == 'alpine' }},suffix=
8383
type=raw,event=tag,value=prerelease-latest,enable=${{ startsWith(github.ref, 'refs/tags/') && contains(github.ref, 'pre') }},suffix=${{ env.SUFFIX }}

0 commit comments

Comments
 (0)