From 308570a8210efc77318dcac496e38255b1b040a7 Mon Sep 17 00:00:00 2001 From: Vincent Boutour Date: Sun, 11 Apr 2021 17:57:26 +0200 Subject: [PATCH] ci: Conditionning docker step with the presence of docker credentials Signed-off-by: Vincent Boutour --- .github/workflows/build.yaml | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 66c21471..0d4ddab4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,6 @@ +--- name: Build + on: push: branches: @@ -6,11 +8,14 @@ on: pull_request: branches: - main + env: SCRIPTS_NO_INTERACTIVE: "true" + defaults: run: shell: bash + jobs: build: name: Golang @@ -25,6 +30,7 @@ jobs: make git --no-pager diff -- ':(exclude)go.sum' && git diff --quiet -- ':(exclude)go.sum' - uses: codecov/codecov-action@v1 + package: name: Docker if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" @@ -32,11 +38,6 @@ jobs: steps: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USER }} - password: ${{ secrets.DOCKER_PASS }} - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: @@ -45,8 +46,24 @@ jobs: run: | curl --disable --silent --show-error --location --max-time 30 "https://raw.githubusercontent.com/ViBiOh/scripts/main/bootstrap" | bash -s "release" ./scripts/release build - DOCKER_IMAGE="${{ secrets.DOCKER_USER }}/$(make name)" IMAGE_VERSION="$(make version)" ./scripts/release docker + - name: Login to DockerHub + if: env.DOCKER_USER && env.DOCKER_PASS + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + - name: Docker + if: env.DOCKER_USER && env.DOCKER_PASS + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} + run: | DOCKER_IMAGE="${{ secrets.DOCKER_USER }}/$(make name)-notifier" IMAGE_VERSION="$(make version)" DOCKERFILE="Dockerfile.notifier" ./scripts/release docker + DOCKER_IMAGE="${{ secrets.DOCKER_USER }}/$(make name)" IMAGE_VERSION="$(make version)" ./scripts/release docker + publish: name: Publish if: