Skip to content

Commit

Permalink
[ADD] helm-release-notify and helm-test-notify
Browse files Browse the repository at this point in the history
  • Loading branch information
alexnuttinck committed Aug 13, 2024
1 parent a3e9c29 commit 7490690
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [v3.9] - 2024-08-13
### Added
- helm-release-notify
- helm-test-notify

## [v3.8] - 2024-08-08
### Added
- plone-theme-build-push-notify
Expand Down
84 changes: 75 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,42 @@
This repository hosts a set of github actions we use to deploy our apps.

## Actions
- [build-push-notify](#build-push-notify)
- [check-url-availibility](#check-url-availibility)
- [code-analysis-notify](#code-analysis-notify)
- [deb-build-push-notify](#deb-build-push-notify)
- [mattermost-notify](#mattermost-notify)
- [plone-package-test-notify](#plone-package-test-notify)
- [plone-theme-build-push-notify](#plone-theme-build-push-notify)
- [rundeck-notify](#rundeck-notify)
- [tag-notify](#tag-notify)
- [iMio github actions](#imio-github-actions)
- [Actions](#actions)
- [build-push-notify](#build-push-notify)
- [Inputs](#inputs)
- [Example of usage](#example-of-usage)
- [check-url-availibility](#check-url-availibility)
- [Example of usage](#example-of-usage-1)
- [code-analysis-notify](#code-analysis-notify)
- [Inputs](#inputs-1)
- [Example of usage](#example-of-usage-2)
- [deb-build-push-notify](#deb-build-push-notify)
- [Inputs](#inputs-2)
- [Example of usage](#example-of-usage-3)
- [helm-release-notify](#helm-release-notify)
- [Inputs](#inputs-3)
- [Example of usage](#example-of-usage-4)
- [helm-test-notify](#helm-test-notify)
- [Inputs](#inputs-4)
- [Example of usage](#example-of-usage-5)
- [mattermost-notify](#mattermost-notify)
- [Inputs](#inputs-5)
- [Example of usage](#example-of-usage-6)
- [plone-package-test-notify](#plone-package-test-notify)
- [Inputs](#inputs-6)
- [Example of usage](#example-of-usage-7)
- [plone-theme-build-push-notify](#plone-theme-build-push-notify)
- [Inputs](#inputs-7)
- [Example of usage](#example-of-usage-8)
- [rundeck-notify](#rundeck-notify)
- [Inputs](#inputs-8)
- [Example of usage](#example-of-usage-9)
- [tag-notify](#tag-notify)
- [Inputs](#inputs-9)
- [Example of usage](#example-of-usage-10)
- [Contribute](#contribute)
- [Release](#release)

### build-push-notify

Expand Down Expand Up @@ -99,6 +126,45 @@ Build a deb package, push it on a repository and optionally notify via a matterm

[IMIO/scripts-teleservices](https://github.com/IMIO/scripts-teleservices/blob/613d1563be3ddbafb3c66347022558c5dffb678c/.github/workflows/deb.yml#L20)

---
### helm-release-notify

Release a helm chart and optionally notify via a mattermost webhook

#### Inputs

| name | required | type | default | description |
| ---------------------- | -------- | ------ | --------------- | ----------- |
| HELM_VERSION | yes | string | "v3.12.3" | Helm version to use |
| HELM_DEPENDENCIES | no | string | | Helm dependencies |
| INDEX_DIR | yes | string | "." | Index directory |
| CHARTS_DIR | yes | string | "." | Charts directory |
| TARGET_DIR | yes | string | "test" | Target directory to release |
| MATTERMOST_WEBHOOK_URL | no | string | | Webhook URL to send notifications on Mattermost |

#### Example of usage

/

---
### helm-test-notify

Lint and test a helm chart and optionally notify via a mattermost webhook

#### Inputs

| name | required | type | default | description |
| ---------------------- | -------- | ------ | --------------- | ----------- |
| PYTHON_VERSION | yes | string | "3.10" | Python version to use |
| HELM_VERSION | yes | string | "v3.12.3" | Helm version to use |
| HELM_RELEASE | yes | string | "test" | Helm release name |
| HELM_NAMESPACE | yes | string | "test" | Helm namespace name |
| MATTERMOST_WEBHOOK_URL | no | string | | Webhook URL to send notifications on Mattermost |

#### Example of usage

/

---
### mattermost-notify

Expand Down
75 changes: 75 additions & 0 deletions helm-release-notify/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Release Helm Chart and Notify
description: Release Helm chart and notify on Mattermost
inputs:
HELM_VERSION:
description: 'Helm version to use'
required: true
default: 'v3.12.3'
HELM_DEPENDENCIES:
description: 'Helm dependencies'
required: false
INDEX_DIR:
description: 'Index directory'
required: true
default: '.'
CHARTS_DIR:
description: 'Charts directory'
required: true
default: '.'
TARGET_DIR:
description: 'Target directory to release'
required: true
default: 'test'
MATTERMOST_WEBHOOK_URL:
description: 'Webhook URL to send notifications on Mattermost'
required: false
runs:
using: 'composite'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: "helm-charts"
- name: Get Helm chart version
id: get-version
run: |
echo ::set-output name=version::$(yq eval '.version' ${{ inputs.CHARTS_DIR }}/Chart.yaml)
shell: bash
- name: Publish Helm chart
uses: tylerauerbeck/helm-gh-pages@main
with:
token: ${{ steps.app-token.outputs.token }}
charts_dir: ${{ inputs.CHARTS_DIR }}
index_dir: ${{ inputes.INDEX_DIR }}
charts_url: https://imio.github.io/helm-charts/
owner: IMIO
repository: helm-charts
branch: gh-pages
target_dir: ${{ inputs.TARGET_DIR }}
helm_version: ${{ inputs.HELM_VERSION }}
dependencies: ${{ inputs.HELM_DEPENDENCIES }}
- name : Send notification on Mattermost
if: ${{ inputs.MATTERMOST_WEBHOOK_URL != '' }}
run: |
JOB_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
MESSAGE="Success : ${{ github.repository }} has published a Helm release with version ${{ steps.get-version.outputs.version }}. [Click here to see job on GitHub]($JOB_URL)"
curl -i -X POST -H 'Content-Type: application/json' -d "{\"text\": \"$MESSAGE\"}" ${{ inputs.MATTERMOST_WEBHOOK_URL }}
shell: bash
- name : Send failure notification on Mattermost
if: ${{ failure() && inputs.MATTERMOST_WEBHOOK_URL != '' }}
env:
IMAGE_NAME: ${{ inputs.IMAGE_NAME }}
IMAGE_TAG: ${{ inputs.IMAGE_TAG }}
NEW_IMAGE_TAGS: ${{ inputs.NEW_IMAGE_TAGS }}
run: |
JOB_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
MESSAGE="Error : Helm release has failed. (Repository: ${{ github.repository }}) [Click here to see job on GitHub]($JOB_URL)"
curl -i -X POST -H 'Content-Type: application/json' -d "{\"text\": \"$MESSAGE\"}" ${{ inputs.MATTERMOST_WEBHOOK_URL }}
shell: bash
63 changes: 63 additions & 0 deletions helm-test-notify/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Lint and Test Helm Chart and Notify
description: Lint and test Helm chart and notify on Mattermost
inputs:
PYTHON_VERSION:
description: 'Python version to use'
required: true
default: '3.10'
HELM_VERSION:
description: 'Helm version to use'
required: true
default: 'v3.12.3'
HELM_RELEASE:
description: 'Helm release name'
required: true
default: 'test'
HELM_NAMESPACE:
description: 'Helm namespace name'
required: true
default: 'test'
MATTERMOST_WEBHOOK_URL:
description: 'Webhook URL to send notifications on Mattermost'
required: false
runs:
using: 'composite'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/[email protected]
with:
version: ${{ inputs.HELM_VERSION }}
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.PYTHON_VERSION }}
check-latest: true
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (lint)
run: ct lint --chart-dirs . --charts . --target-branch ${{ github.event.repository.default_branch }}
shell: bash
- name: Create kind cluster
uses: helm/[email protected]
- name: Run chart-testing (install)
# run: ct install --chart-dirs . --charts . --target-branch ${{ github.event.repository.default_branch }}
# can't use it until https://github.com/helm/chart-testing/issues/310 is resolved
run: helm install ${{ inputs.HELM_RELEASE }} . -f values.yaml --namespace ${{ inputs.HELM_NAMESPACE }} --create-namespace
shell: bash
- name : Send notification on Mattermost
if: ${{ inputs.MATTERMOST_WEBHOOK_URL != '' }}
run: |
JOB_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
MESSAGE="Success : helm lint and tests. (Repository: ${{ github.repository }}, Branch: ${{ github.ref_name }}, Commit: ${{ github.sha }}) [Click here to see job on GitHub]($JOB_URL)"
curl -i -X POST -H 'Content-Type: application/json' -d "{\"text\": \"$MESSAGE\"}" ${{ inputs.MATTERMOST_WEBHOOK_URL }}
shell: bash
- name : Send failure notification on Mattermost
if: ${{ failure() && inputs.MATTERMOST_WEBHOOK_URL != '' }}
run: |
JOB_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
MESSAGE="Error : helm lint and tests have failed. (Repository: ${{ github.repository }}, Branch: ${{ github.ref_name }}, Commit: ${{ github.sha }}) [Click here to see job on GitHub]($JOB_URL)"
curl -i -X POST -H 'Content-Type: application/json' -d "{\"text\": \"$MESSAGE\"}" ${{ inputs.MATTERMOST_WEBHOOK_URL }}
shell: bash

0 comments on commit 7490690

Please sign in to comment.