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 }}
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