refactor: move credentials checks into their own job

Lays the groundwork for splitting the `docker` job into `candidates` and `releases`.

PR: #41
This commit is contained in:
innovaker 2021-05-14 19:12:34 +01:00
parent 0df3be0b73
commit 40f6d7bf50

View File

@ -13,6 +13,20 @@ on:
concurrency: ${{ github.workflow }} concurrency: ${{ github.workflow }}
jobs: 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: architectures:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
@ -30,6 +44,7 @@ jobs:
print('::set-output name=json::' + json.dumps(architectures)) print('::set-output name=json::' + json.dumps(architectures))
docker: docker:
needs: needs:
- credentials
- architectures - architectures
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
@ -40,24 +55,16 @@ jobs:
- dev - dev
- build - build
steps: 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 - name: Login to Docker Hub
id: docker-hub-login id: docker-hub-login
if: ${{ steps.docker-hub-credentials.outcome == 'success' }} if: ${{ needs.credentials.outputs.docker-hub == 'true' }}
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
username: ${{ secrets.DOCKER_HUB_USERNAME }} username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }} 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 - name: Login to GitHub Container Registry
id: ghcr-login id: ghcr-login
if: ${{ steps.ghcr-credentials.outcome == 'success' }} if: ${{ needs.credentials.outputs.ghcr == 'true' }}
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
registry: ghcr.io registry: ghcr.io