Skip to content

Commit 8cc00c7

Browse files
Wieneomaboehm
andauthored
Add Github action for publishing Helm OCI artifacts (#516)
Co-authored-by: Marcel Boehm <[email protected]>
1 parent 8400179 commit 8cc00c7

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

.github/workflows/images.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ on:
88
- v*
99

1010
jobs:
11+
helm-oci:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
- uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
25+
- uses: azure/[email protected]
26+
- name: Push artifacts
27+
run: PUSH=true hack/push-artifacts.sh ghcr.io/stackitcloud/yawol/yawol-controller
1128
build:
1229
runs-on: ubuntu-latest
1330
permissions:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
artifacts
2+
13
# Binaries for programs and plugins
24
*.exe
35
*.exe~

hack/push-artifacts.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
chart_name=yawol-controller
8+
helm_artifacts=artifacts/charts
9+
rm -rf "$helm_artifacts"
10+
mkdir -p "$helm_artifacts"
11+
12+
function image_registry() {
13+
echo "$1" | cut -d '/' -f -2
14+
}
15+
16+
function image_repo() {
17+
echo "$1" | cut -d ':' -f 1
18+
}
19+
20+
function image_tag() {
21+
git describe --tag --always --dirty
22+
}
23+
24+
## HELM
25+
cp -r charts/${chart_name} "$helm_artifacts"
26+
yq -i "\
27+
( .image.repository = \"$(image_repo "$1")\" ) | \
28+
( .image.tag = \"$(image_tag "$1")\" )\
29+
" "$helm_artifacts/${chart_name}/values.yaml"
30+
31+
# push to registry
32+
if [ "${PUSH:=}" != "true" ] ; then
33+
echo "Skip pushing artifacts because PUSH is not set to 'true'"
34+
exit 0
35+
fi
36+
37+
helm package "$helm_artifacts/${chart_name}" --version "$(image_tag "$1")" -d "$helm_artifacts" > /dev/null 2>&1
38+
helm push "$helm_artifacts/${chart_name}-"* "oci://$(image_registry "$1")/charts"

0 commit comments

Comments
 (0)