From 2bb7ef26d1f3feb1121459cf5ed8c2ecb8accec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Wenzel?= Date: Wed, 20 Oct 2021 11:06:17 +0200 Subject: [PATCH] switch github action workflow to if condition for docker build --- .github/workflows/docker.yaml | 40 ----------------------------------- .github/workflows/maven.yaml | 29 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 40 deletions(-) delete mode 100644 .github/workflows/docker.yaml diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml deleted file mode 100644 index 9c4c55e..0000000 --- a/.github/workflows/docker.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Docker - -on: - workflow_run: - workflows: - - Java CI - branches: - - master - tags: - - "*" - types: - - completed - - -jobs: - docker: - if: ${{ github.event.workflow_run.conclusion == 'success' }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set output - id: vars - run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - push: true - tags: daspawnw/vault-crd:${{ steps.vars.outputs.tag }} diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index dc4bd06..0593693 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -36,3 +36,32 @@ jobs: - name: Build with Maven run: mvn -B package --file pom.xml -Dspring.profiles.active=test + docker: + name: Docker Build + + runs-on: ubuntu-latest + + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') + + steps: + - uses: actions/checkout@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set output + id: vars + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: daspawnw/vault-crd:${{ steps.vars.outputs.tag }}