Skip to content

Commit

Permalink
feat(helm): Add app helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
tarampampam committed Feb 1, 2025
1 parent a568df6 commit a0d0237
Show file tree
Hide file tree
Showing 11 changed files with 969 additions and 35 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,53 @@ jobs:
docker.io/tarampampam/webhook-tester:${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}
docker.io/tarampampam/webhook-tester:${{ steps.slug.outputs.version-major }}
helm-pack:
name: Pack the Helm chart
runs-on: ubuntu-latest
defaults: {run: {working-directory: ./chart}}
steps:
- uses: actions/checkout@v4
- uses: azure/setup-helm@v4
- {uses: gacts/github-slug@v1, id: slug}
- run: |
helm package \
--app-version "${{ steps.slug.outputs.version }}" \
--version "${{ steps.slug.outputs.version }}" .
- uses: actions/upload-artifact@v4
with:
name: helm-chart
path: ./chart/*.tgz
if-no-files-found: error
retention-days: 1

helm-publish:
name: Put the Helm chart to the GitHub pages branch
runs-on: ubuntu-latest
needs: [helm-pack]
steps:
- {uses: actions/checkout@v4, with: {ref: gh-pages}}
- uses: azure/setup-helm@v4
- name: Configure git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- uses: actions/download-artifact@v4
with: {name: helm-chart, path: ./helm-charts}
- name: Update the index.yaml
run: |
helm repo index \
--url https://${{ github.actor }}.github.io/${{ github.event.repository.name }}/helm-charts/ \
--merge \
./helm-charts/index.yaml \
./helm-charts
- name: Update the index.html
run: tree -H '.' --noreport --dirsfirst -T 'Index' --charset utf-8 -P "*.tgz" -o ./index.html
- name: Commit and push the changes
run: |
git add 'helm-charts/*' index.html
git commit -m "Helm chart release"
git push origin gh-pages
deploy-on-render:
name: Deploy on Render
runs-on: ubuntu-latest
Expand Down
70 changes: 41 additions & 29 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,43 @@ jobs:
- {uses: actions/checkout@v4, with: {fetch-depth: 0}}
- uses: gacts/gitleaks@v1

filter:
name: Filter files
runs-on: ubuntu-latest
permissions: {pull-requests: read}
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
docker: ${{ steps.filter.outputs.docker }}
helm: ${{ steps.filter.outputs.helm }}
steps:
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
backend: ['api/**', 'cmd/**', 'internal/**', '*go*', 'web/**/*.go']
frontend: ['api/**', 'web/**']
docker: [Dockerfile, '*docker*']
helm: ['chart/**', '*kube*']
lint-charts:
name: Lint the chart
runs-on: ubuntu-latest
needs: [filter]
if: needs.filter.outputs.helm == 'true'
defaults: {run: {working-directory: ./chart}}
steps:
- uses: actions/checkout@v4
- uses: azure/setup-helm@v4
- run: helm dependency update .
- run: helm template . > /dev/null
- run: helm lint --strict .

lint-and-test-backend:
name: Test and lint the backend
runs-on: ubuntu-latest
needs: [filter]
if: needs.filter.outputs.backend == 'true'
steps:
- uses: actions/checkout@v4
- {uses: actions/setup-go@v5, with: {go-version-file: go.mod}}
Expand All @@ -38,6 +72,8 @@ jobs:
lint-and-test-frontend:
name: Test and lint the frontend
runs-on: ubuntu-latest
needs: [filter]
if: needs.filter.outputs.frontend == 'true'
env: {FORCE_COLOR: 'true', NPM_PREFIX: './web'}
steps:
- uses: actions/checkout@v4
Expand All @@ -51,6 +87,8 @@ jobs:
build-web:
name: Build the frontend
runs-on: ubuntu-latest
needs: [filter] # since this is the initial step, we can filter out the rest of the jobs right here to skip them
if: ${{ needs.filter.outputs.backend == 'true' || needs.filter.outputs.frontend == 'true' }}
env: {FORCE_COLOR: 'true', NPM_PREFIX: './web'}
steps:
- uses: actions/checkout@v4
Expand All @@ -70,7 +108,7 @@ jobs:
matrix: # https://pkg.go.dev/internal/platform
os: [linux, darwin, windows]
arch: [amd64, arm64]
needs: [lint-and-test-backend, lint-and-test-frontend, build-web]
needs: [build-web]
steps:
- uses: actions/checkout@v4
- {uses: gacts/github-slug@v1, id: slug}
Expand All @@ -95,33 +133,6 @@ jobs:
if-no-files-found: error
retention-days: 7

build-deb-package:
name: Build the Debian package
runs-on: ubuntu-latest
strategy: {matrix: {arch: [amd64, arm64]}}
needs: [build-app]
steps:
- {uses: gacts/github-slug@v1, id: slug}
- {uses: actions/download-artifact@v4, with: {name: "webhook-tester-linux-${{ matrix.arch }}"}}
- id: values
run: |
majorMinorPatch="${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}.${{ steps.slug.outputs.version-patch }}"
echo "version=${majorMinorPatch}" >> $GITHUB_OUTPUT
echo "pkg-name=webhook-tester_${majorMinorPatch}-1_${{ matrix.arch }}" >> $GITHUB_OUTPUT
- run: |
mkdir -p ./${{ steps.values.outputs.pkg-name }}/usr/local/bin ./${{ steps.values.outputs.pkg-name }}/DEBIAN
mv ./webhook-tester-linux-${{ matrix.arch }} ./${{ steps.values.outputs.pkg-name }}/usr/local/bin/webhook-tester
echo -e "Package: webhook-tester\nVersion: ${{ steps.values.outputs.version }}" > ./${{ steps.values.outputs.pkg-name }}/DEBIAN/control
echo -e "Architecture: ${{ matrix.arch }}\nMaintainer: ${{ github.actor }}" >> ./${{ steps.values.outputs.pkg-name }}/DEBIAN/control
echo -e "Description: Powerful tool for testing WebHooks and more" >> ./${{ steps.values.outputs.pkg-name }}/DEBIAN/control
dpkg-deb --build --root-owner-group ${{ steps.values.outputs.pkg-name }}
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.values.outputs.pkg-name }}.deb
path: ./${{ steps.values.outputs.pkg-name }}.deb
if-no-files-found: error
retention-days: 7

e2e-test:
name: End-to-end tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -155,7 +166,8 @@ jobs:
build-docker-image:
name: Build the docker image
runs-on: ubuntu-latest
needs: [lint-and-test-backend, lint-and-test-frontend]
needs: [filter]
if: needs.filter.outputs.docker == 'true'
steps:
- uses: actions/checkout@v4
- uses: docker/build-push-action@v6
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ You'll never miss a request!

## ⁉ FAQ

**Can I have pre-defined (static) webhook URLs (sessions) to ensure that the sent request will be captured even
**Can I have pre-defined (static) webhook URLs (sessions) to ensure that the sent request will be captured even
without data persistence?**

Yes, simply use the `--auto-create-sessions` flag or set the `AUTO_CREATE_SESSIONS=true` environment variable. In
`v1`, you needed to define sessions during app startup to enable this functionality. However, since `v2`, all you
need to do is enable this feature. It works quite simply - if the incoming request contains a UUID-formatted prefix
(e.g., `http://app/11111111-2222-3333-4444-555555555555/...`), a session for this request will be created
automatically. All that's left for you to do is open the session in the UI
Yes, simply use the `--auto-create-sessions` flag or set the `AUTO_CREATE_SESSIONS=true` environment variable. In
`v1`, you needed to define sessions during app startup to enable this functionality. However, since `v2`, all you
need to do is enable this feature. It works quite simply - if the incoming request contains a UUID-formatted prefix
(e.g., `http://app/11111111-2222-3333-4444-555555555555/...`), a session for this request will be created
automatically. All that's left for you to do is open the session in the UI
(`http://app/s/11111111-2222-3333-4444-555555555555`).

## 🧩 Installation
Expand Down Expand Up @@ -112,6 +112,10 @@ Alternatively, you can use the Docker image:
> It’s recommended to avoid using the `latest` tag, as **major** upgrades may include breaking changes.
> Instead, use specific tags in `X.Y.Z` format for version consistency.
To install it on Kubernetes (K8s), please use the Helm chart from [ArtifactHUB][artifact-hub].

[artifact-hub]:https://artifacthub.io/packages/helm/webhook-tester/webhook-tester

## ⚙ Usage

The easiest way to run the app is by using the Docker image:
Expand Down
11 changes: 11 additions & 0 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# yaml-language-server: $schema=https://json.schemastore.org/chart.json

apiVersion: v2
name: webhook-tester
description: Powerful tool for testing WebHooks and more

type: application
version: 0.1.0
appVersion: 2.0.1
icon: https://github.com/user-attachments/assets/e2e659dc-7fb1-4ac2-ad3c-883899f5fc38
sources: [https://github.com/tarampampam/webhook-tester]
28 changes: 28 additions & 0 deletions chart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# WebHook Tester

## Usage

```shell
helm repo add tarampampam https://tarampampam.github.io/webhook-tester/helm-charts
helm repo update

helm install webhook-tester tarampampam/webhook-tester
```

Alternatively, add the following lines to your `Chart.yaml`:

```yaml
dependencies:
- name: webhook-tester
version: <version>
repository: https://tarampampam.github.io/webhook-tester/helm-charts
```
And override the default values in your `values.yaml`:

```yaml
webhook-tester:
# ...
service: {port: 8800}
# ...
```
52 changes: 52 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{/* Define namespace of chart, useful for multi-namespace deployments */}}
{{- define "webhook-tester.namespace" -}}
{{- if .Values.namespaceOverride }}
{{- .Values.namespaceOverride }}
{{- else }}
{{- .Release.Namespace }}
{{- end }}
{{- end }}

{{/* Expand the name of the chart */}}
{{- define "webhook-tester.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "webhook-tester.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/* Create chart name and version as used by the chart label */}}
{{- define "webhook-tester.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/* Common labels */}}
{{- define "webhook-tester.commonLabels" -}}
helm.sh/chart: {{ include "webhook-tester.chart" . }}
{{ include "webhook-tester.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/* Selector labels */}}
{{- define "webhook-tester.selectorLabels" -}}
app.kubernetes.io/name: {{ include "webhook-tester.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
Loading

0 comments on commit a0d0237

Please sign in to comment.