From 40f6d7bf50372132159779cc6af7e7374fd87ab7 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Fri, 14 May 2021 19:12:34 +0100 Subject: [PATCH] refactor: move credentials checks into their own job Lays the groundwork for splitting the `docker` job into `candidates` and `releases`. PR: #41 --- .github/workflows/containers.yml | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index a8f34c5..147e97e 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -13,6 +13,20 @@ on: concurrency: ${{ github.workflow }} jobs: + credentials: + runs-on: ubuntu-latest + outputs: + ghcr: ${{ steps.ghcr.outcome == 'success' }} + docker-hub: ${{ steps.docker-hub.outcome == 'success' }} + steps: + - name: Docker Hub + id: docker-hub + run: if [ ${{ secrets.DOCKER_HUB_USERNAME == null || secrets.DOCKER_HUB_TOKEN == null }} = true ]; then exit 1; fi + continue-on-error: true + - name: GitHub Container Registry + id: ghcr + run: if [ ${{ secrets.GHCR_USERNAME == null || secrets.GHCR_TOKEN == null }} = true ]; then exit 1; fi + continue-on-error: true architectures: runs-on: ubuntu-latest outputs: @@ -30,6 +44,7 @@ jobs: print('::set-output name=json::' + json.dumps(architectures)) docker: needs: + - credentials - architectures runs-on: ubuntu-latest strategy: @@ -40,24 +55,16 @@ jobs: - dev - build steps: - - name: Check for Docker Hub credentials (secrets) - id: docker-hub-credentials - run: if [ ${{ secrets.DOCKER_HUB_USERNAME == null || secrets.DOCKER_HUB_TOKEN == null }} = true ]; then exit 1; fi - continue-on-error: true - name: Login to Docker Hub id: docker-hub-login - if: ${{ steps.docker-hub-credentials.outcome == 'success' }} + if: ${{ needs.credentials.outputs.docker-hub == 'true' }} uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_TOKEN }} - - name: Check for GitHub Container Registry credentials (secrets) - id: ghcr-credentials - run: if [ ${{ secrets.GHCR_USERNAME == null || secrets.GHCR_TOKEN == null }} = true ]; then exit 1; fi - continue-on-error: true - name: Login to GitHub Container Registry id: ghcr-login - if: ${{ steps.ghcr-credentials.outcome == 'success' }} + if: ${{ needs.credentials.outputs.ghcr == 'true' }} uses: docker/login-action@v1 with: registry: ghcr.io