fix(ci): only push docker dev tag on main (#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
This commit is contained in:
Dylan Page
2023-05-11 22:34:14 -04:00
committed by GitHub
parent b3782ee62c
commit 3c27fbbfc0

View File

@@ -31,8 +31,8 @@ jobs:
env:
# Set docker repo to either the fork or the main repo where the branch exists
DOCKER_REPO: ghcr.io/${{ github.repository }}
# Push if not a pull request or this is a fork
PUSH: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}
# Push if not a pull request and references the main branch
PUSH: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
@@ -75,9 +75,9 @@ jobs:
type=semver,pattern={{version}},prefix=v,enable=${{ matrix.image_type == 'alpine' }}
type=semver,pattern={{major}}.{{minor}},prefix=v,suffix=${{ env.SUFFIX }}
# dev
type=raw,value=dev,suffix=${{ env.SUFFIX }}-{{ sha }}
type=raw,event=push,value=dev,enable=${{ github.ref == format('refs/heads/{0}', 'main') && matrix.image_type == 'alpine' }},suffix=
type=raw,event=push,value=dev,enable={{is_default_branch}},suffix=${{ env.SUFFIX }}
type=raw,event=push,value=dev,enable={{is_default_branch}},suffix=${{ env.SUFFIX }}-{{ sha }}
type=raw,event=push,value=dev,enable=${{ github.ref == format('refs/heads/{0}', 'main') && matrix.image_type == 'alpine' }},suffix=
# prerelease
type=raw,event=tag,value=prerelease-latest,enable=${{ startsWith(github.ref, 'refs/tags/') && contains(github.ref, 'pre') && matrix.image_type == 'alpine' }},suffix=
type=raw,event=tag,value=prerelease-latest,enable=${{ startsWith(github.ref, 'refs/tags/') && contains(github.ref, 'pre') }},suffix=${{ env.SUFFIX }}