Push Docker image on tag

This commit is contained in:
Manuel Rüger 2023-04-03 13:25:26 +02:00
parent eade059cad
commit 429bbf9bff

View File

@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Go 1.x - name: Set up Go 1.x
uses: actions/setup-go@v3 uses: actions/setup-go@v4
with: with:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}
id: go id: go
@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Go 1.x - name: Set up Go 1.x
uses: actions/setup-go@v3 uses: actions/setup-go@v4
with: with:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}
id: go id: go
@ -53,7 +53,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up Go 1.x - name: Set up Go 1.x
uses: actions/setup-go@v3 uses: actions/setup-go@v4
with: with:
go-version: ${{ env.GO_VERSION }} go-version: ${{ env.GO_VERSION }}
id: go id: go
@ -65,7 +65,7 @@ jobs:
run: | run: |
make build make build
# Build Dockerimage # Build and push Dockerimage
ci-docker-build: ci-docker-build:
name: ci-docker-build name: ci-docker-build
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -76,8 +76,25 @@ jobs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v2
- name: Build and push - name: Build only (on commits)
uses: docker/build-push-action@v4 uses: docker/build-push-action@v4
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
with: with:
push: false push: false
tags: kovetskiy/mark:latest 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