From 89f2f78972d0c78bc34a68e4c057c403da4fde86 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sun, 23 May 2021 22:07:09 +0100 Subject: 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) --- .github/workflows/images.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/images.yml b/.github/workflows/images.yml index 87fae3b..1a1a2d9 100644 --- a/.github/workflows/images.yml +++ b/.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' -- cgit v1.1