Skip to content

Commit 264ca3b

Browse files
config: Update workflow file to build image on specific version release
1 parent 019dc58 commit 264ca3b

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

.github/workflows/action.yaml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,34 @@ name: Build and Push Docker Image for Helm Client
33
on:
44
push:
55
branches:
6+
- main
67
- 'v*.*.*'
8+
pull_request:
9+
types: [closed]
710

811
jobs:
9-
build-and-publish-image:
12+
build-and-publish-image:
1013
runs-on: ubuntu-latest
11-
steps:
1214

15+
steps:
1316
- name: Checkout
1417
uses: actions/checkout@v3
15-
18+
1619
- name: Extract branch name
17-
shell: bash
18-
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
1920
id: branch_name
21+
shell: bash
22+
run: |
23+
echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
24+
25+
- name: Set Docker tag
26+
id: docker_tag
27+
shell: bash
28+
run: |
29+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
30+
echo "tag=latest" >> $GITHUB_OUTPUT
31+
elif [[ "${{ github.ref }}" == refs/heads/v* ]]; then
32+
echo "tag=${{ steps.branch_name.outputs.branch }}" >> $GITHUB_OUTPUT
33+
fi
2034
2135
- name: Set up QEMU
2236
uses: docker/setup-qemu-action@v2
@@ -30,9 +44,17 @@ jobs:
3044
username: ${{ secrets.DOCKER_USERNAME }}
3145
password: ${{ secrets.DOCKER_PASSWORD }}
3246

33-
- name: Build and push
47+
- name: Build and push Docker image
3448
uses: docker/build-push-action@v4
3549
with:
3650
push: true
3751
platforms: linux/amd64
38-
tags: ${{ secrets.DOCKER_REPO }}/helm-client:${{ steps.branch_name.outputs.branch }}
52+
tags: ${{ secrets.DOCKER_REPO }}/helm-client:${{ steps.docker_tag.outputs.tag }}
53+
54+
- name: Update Docker Hub description
55+
if: github.ref == 'refs/heads/main'
56+
uses: peter-evans/dockerhub-description@v3
57+
with:
58+
username: ${{ secrets.DOCKER_USERNAME }}
59+
password: ${{ secrets.DOCKER_PASSWORD }}
60+
repository: ${{ secrets.DOCKER_REPO }}/helm-client

0 commit comments

Comments
 (0)