Skip to content

Commit

Permalink
CI: Don't try to push docker image in a forked repository
Browse files Browse the repository at this point in the history
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
actions/runner#520)
  • Loading branch information
jon-turney committed Jun 3, 2021
1 parent 201dc64 commit b5e2d4f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ on:

jobs:
build:
env:
HAS_DOCKER_CREDENTIALS: ${{ secrets.DOCKER_PASSWORD != '' }}
name: ${{ matrix.cfg.name }}
runs-on: ubuntu-latest
strategy:
Expand All @@ -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 }}
Expand All @@ -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'

0 comments on commit b5e2d4f

Please sign in to comment.