From 429bbf9bffcc8ab5e7a586bd6da8893abd93d10b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 3 Apr 2023 13:25:26 +0200 Subject: [PATCH] Push Docker image on tag --- .github/workflows/ci.yml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b57e727..e978dbb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go 1.x - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: ${{ env.GO_VERSION }} id: go @@ -35,7 +35,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go 1.x - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: ${{ env.GO_VERSION }} id: go @@ -53,7 +53,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go 1.x - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: ${{ env.GO_VERSION }} id: go @@ -65,7 +65,7 @@ jobs: run: | make build - # Build Dockerimage + # Build and push Dockerimage ci-docker-build: name: ci-docker-build runs-on: ubuntu-latest @@ -76,8 +76,25 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Build and push + - name: Build only (on commits) uses: docker/build-push-action@v4 + if: ${{ ! startsWith(github.ref, 'refs/tags/') }} with: push: false tags: kovetskiy/mark:latest + + - name: Login to Docker Hub + uses: docker/login-action@v2 + if: ${{ startsWith(github.ref, 'refs/tags/') }} + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build and push (on tag) + uses: docker/build-push-action@v4 + if: ${{ startsWith(github.ref, 'refs/tags/') }} + with: + push: true + tags: | + kovetskiy/mark:${{ steps.extract_tag.outputs.tag }} + kovetskiy/mark:latest