Only push CI's Docker images when we're on the main repo

This commit is contained in:
Christian Kreibich 2021-11-03 15:22:20 -07:00
parent bac833a2f9
commit c1ebb279ca

View file

@ -27,6 +27,7 @@ jobs:
# Create and boot a loader. This will e.g., provide caching # Create and boot a loader. This will e.g., provide caching
# so we avoid rebuilds of the same image after this step. # so we avoid rebuilds of the same image after this step.
- uses: docker/setup-buildx-action@v1 - uses: docker/setup-buildx-action@v1
- name: Build - name: Build
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
@ -43,6 +44,7 @@ jobs:
- name: Get version - name: Get version
id: version id: version
run: echo "::set-output name=RELEASE_VERSION::$(cat VERSION)" run: echo "::set-output name=RELEASE_VERSION::$(cat VERSION)"
- name: Compute target tag - name: Compute target tag
id: target id: target
env: env:
@ -65,15 +67,16 @@ jobs:
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@v1 uses: docker/login-action@v1
# Secrets for the login are not available for pull requests. # Don't publish on forks. Also note that secrets for the login are not
if: github.event_name == 'push' # available for pull requests, so trigger on pushes only.
if: github.repository == 'zeek/zeek' && github.event_name == 'push'
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push - name: Push
# Only publish if we did compute a tag. # Only publish if we did compute a tag.
if: github.event_name == 'push' && steps.target.outputs.tag != '' if: github.repository == 'zeek/zeek' && github.event_name == 'push' && steps.target.outputs.tag != ''
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: ./ context: ./