Skip to content

Commit 614b1a4

Browse files
committed
changed docker-build action
1 parent 37e0f6a commit 614b1a4

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

.github/workflows/docker-build.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,41 @@ name: update docker image
22

33
on:
44
push:
5+
branches:
6+
- dev
7+
- master
58
tags:
69
- 'v*.*.*'
710

811
jobs:
912
build:
1013
runs-on: ubuntu-latest
1114
steps:
12-
-
13-
name: Login to Docker Hub
15+
- name: set docker image tag
16+
run: |
17+
echo "CREATE_IMAGE=true" >> $env:GITHUB_ENV
18+
if [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
19+
echo "IMAGE_TAG=dev" >> $env:GITHUB_ENV
20+
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
21+
echo "IMAGE_TAG=${{ github.ref_name }}"
22+
else
23+
echo "CREATE_IMAGE=false" >> $env:GITHUB_ENV
24+
fi
25+
26+
- name: Login to Docker Hub
1427
uses: docker/login-action@v3
28+
if: env.CREATE_IMAGE == 'true'
1529
with:
1630
username: ${{ vars.DOCKERHUB_USERNAME }}
1731
password: ${{ secrets.DOCKERHUB_TOKEN }}
18-
-
19-
name: Set up Docker Buildx
32+
33+
- name: Set up Docker Buildx
2034
uses: docker/setup-buildx-action@v3
21-
-
22-
name: Build and push
35+
if: env.CREATE_IMAGE == 'true'
36+
37+
- name: Build and push
2338
uses: docker/build-push-action@v6
39+
if: env.CREATE_IMAGE == 'true'
2440
with:
2541
push: true
26-
tags: ${{ vars.DOCKERHUB_USERNAME }}/rdgen:latest
42+
tags: ${{ vars.DOCKERHUB_USERNAME }}/${{ github.repository }}:${{ env.IMAGE_TAG }}

0 commit comments

Comments
 (0)