Skip to content

Commit

Permalink
CI: Improve how images workflow works in forks
Browse files Browse the repository at this point in the history
Use the respository owner name rather than hardcoding 'mesonbuild'

Also don't try to push to docker if docker credentials aren't in secrets
(has to be written rather indirectly due to actions/runner#520)
  • Loading branch information
jon-turney committed May 23, 2021
1 parent d6c76d4 commit ffdca6f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 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'
run: docker push ${{ github.repository_owner }}/{{ matrix.cfg.id }}

0 comments on commit ffdca6f

Please sign in to comment.