Skip to content

Commit

Permalink
add helm chart release pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Haley <[email protected]>
  • Loading branch information
charlie-haley committed Apr 11, 2024
1 parent b3b2c08 commit bdc3c09
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/chart-testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
remote: origin
target-branch: main
debug: true
check-version-increment: true
upgrade: true
validate-chart-schema: true
validate-yaml: true
12 changes: 12 additions & 0 deletions .github/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

CT_ARGS=""
GIT_SAFE_DIR="false"

if [ "$GIT_SAFE_DIR" != "true" ]; then
git config --global --add safe.directory /charts/chart
fi

CT_ARGS="--charts ${PWD}/charts"

ct lint --config=./.github/chart-testing.yaml
3 changes: 3 additions & 0 deletions .github/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

/usr/bin/helm unittest --color ./chart/benthos-captain;
68 changes: 68 additions & 0 deletions .github/workflows/release-chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Release Chart

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name blobbot-helm
git config user.email [email protected]
- name: Get chart.yaml verison
id: chart_version
run: |
echo "CHART_VERSION=$(grep -o 'version: [0-9.]*' Chart.yaml | awk '{print $2}')" >> $GITHUB_OUTPUT
- name: Check if tag exists
id: tag_exists
run: |
if ! git show-ref --verify --quiet "refs/tags/chart-${{ steps.chart_version.outputs.CHART_VERSION }}"; then
TAG_EXISTS=false
else
TAG_EXISTS=true
fi
echo "TAG_EXISTS=$TAG_EXISTS" >> $GITHUB_OUTPUT
- name: Tag release
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ steps.chart_version.outputs.CHART_VERSION }}
tag_prefix: "chart-"
if: steps.tag_exists.outputs.TAG_EXISTS == 'false'

- name: Create release
if: steps.tag_exists.outputs.TAG_EXISTS == 'false'
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}

- name: Publish Helm chart
if: steps.tag_exists.outputs.TAG_EXISTS == 'false'
uses: stefanprodan/helm-gh-pages@89c6698c192e70ed0e495bee7d3d1ca5b477fe82
with:
token: ${{ secrets.CHARTS_REPO_TOKEN }}
owner: benthosdev
repository: charts
branch: main
target_dir: benthos
index_dir: .
charts_dir: chart/
charts_url: https://benthosdev.github.io/charts
commit_username: blobbot-helm
commit_email: [email protected]
26 changes: 26 additions & 0 deletions .github/workflows/test-chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test chart

on:
push:
branches:
- main
workflow_call:
workflow_dispatch:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Test
run: make chart-test
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

chart-test: chart-lint
docker run ${DOCKER_ARGS} --entrypoint /bin/sh --rm -v $(CURDIR):/charts -w /charts helmunittest/helm-unittest:3.11.1-0.3.0 /charts/.github/test.sh

chart-lint:
docker run ${DOCKER_ARGS} --env GIT_SAFE_DIR="true" --entrypoint /bin/sh --rm -v $(CURDIR):/charts -w /charts quay.io/helmpack/chart-testing:v3.10.1 /charts/.github/lint.sh

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
Expand Down

0 comments on commit bdc3c09

Please sign in to comment.