Skip to content

Commit 898a1bb

Browse files
committed
Build and publish chart on any version bump
1 parent 896b63e commit 898a1bb

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

.github/workflows/helm-build-push.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,50 @@ name: Publish Danswer Helm Chart
22

33
on:
44
push:
5-
branches:
6-
- main
75
workflow_dispatch:
86

97
jobs:
8+
helm_chart_version_check:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
version_changed: ${{ steps.version_check.outputs.chart_version_changed }}
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
# Check if current chart version exists in releases already
19+
- name: Check for Helm chart version bump
20+
id: version_check
21+
run: |
22+
set -xe
23+
chart_version=$(yq .version deployment/helm/Chart.yaml)
24+
if [[ $(curl https://api.github.com/repos/stackhpc/danswer/releases | jq '.[].tag_name' | grep danswer-helm-$chart_version) ]]; then
25+
echo chart_version_changed=false >> $GITHUB_OUTPUT
26+
else
27+
echo chart_version_changed=true >> $GITHUB_OUTPUT
28+
fi
29+
1030
release:
1131
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
1232
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
1333
permissions:
1434
contents: write
1535
runs-on: ubuntu-latest
36+
needs: helm_chart_version_check
37+
if: ${{ needs.helm_chart_version_check.outputs.version_changed == 'true' }}
1638
steps:
1739
- name: Checkout
18-
uses: actions/checkout@v3
40+
uses: actions/checkout@v4
1941
with:
2042
fetch-depth: 0
2143

2244
# We mark any builds on main branch as latest GH release
2345
# so make sure we don't accidentally use a pre-release tag.
2446
- name: Fail on semver pre-release chart version
2547
run: yq .version deployment/helm/Chart.yaml | grep -v '[a-zA-Z-]'
26-
if: ${{ github.ref_name == 'main'}}
48+
if: ${{ github.ref_name == 'main' }}
2749

2850
# To reduce resource usage images are built only on tag.
2951
# To build a new set of images after committing and pushing

0 commit comments

Comments
 (0)