CI: Don't try to push docker image in a forked repository

The 'build images' workflow runs on a schedule, so will run (and fail)
weekly in every fork.

Don't try to push to docker if docker credentials aren't in repository
secrets.

(A test for that has to be written rather indirectly due to
https://github.com/actions/runner/issues/520)
pull/8869/head
Jon Turney 4 years ago committed by Daniel Mensinger
parent e686545fce
commit 89f2f78972
  1. 6
      .github/workflows/images.yml

@ -21,6 +21,8 @@ on:
jobs:
build:
env:
HAS_DOCKER_CREDENTIALS: ${{ secrets.DOCKER_PASSWORD != '' }}
name: ${{ matrix.cfg.name }}
runs-on: ubuntu-latest
strategy:
@ -38,7 +40,7 @@ jobs:
# Login to dockerhub
- name: Docker login
if: github.event_name == 'push' || github.event_name == 'schedule'
if: (github.event_name == 'push' || github.event_name == 'schedule') && env.HAS_DOCKER_CREDENTIALS == 'true'
uses: azure/docker-login@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
@ -52,5 +54,5 @@ jobs:
# Publish
- name: Push the ${{ matrix.cfg.id }} image
if: github.event_name == 'push' || github.event_name == 'schedule'
run: docker push mesonbuild/${{ matrix.cfg.id }}
if: (github.event_name == 'push' || github.event_name == 'schedule') && env.HAS_DOCKER_CREDENTIALS == 'true'

Loading…
Cancel
Save