Skip to content

Commit

Permalink
feat: added action for lint and deploy
Browse files Browse the repository at this point in the history
Signed-off-by: ffais <[email protected]>
  • Loading branch information
ffais committed Oct 29, 2024
1 parent ac8414d commit c6adfaa
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 59 deletions.
10 changes: 10 additions & 0 deletions .github/linters/ct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# See https://github.com/helm/chart-testing#configuration
remote: origin
target-branch: main
chart-repos:
- bitnami=https://charts.bitnami.com/bitnami
helm-extra-args: --timeout 600s

additional-commands:
- sh -ec "if [ -f '{{ .Path }}/ci/lint.sh' ]; then shellcheck '{{ .Path }}/ci/lint.sh'; bash '{{ .Path }}/ci/lint.sh'; fi"
# - helm unittest --helm3 --strict --file unittests/*.yaml --file 'unittests/**/*.yaml' {{ .Path }}
55 changes: 0 additions & 55 deletions .github/workflows/build_push_image.yaml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Lint and Test Charts

on: pull_request

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

- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.16.2

- uses: actions/setup-python@v5
with:
python-version: '3.7'

- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed="$(ct list-changed --config .github/linters/ct.yaml)"
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
# - name: install helm unittest plugin
# if: steps.list-changed.outputs.changed == 'true'
# run: |
# helm env
# helm plugin install https://github.com/quintush/helm-unittest.git --version 0.2.8

- name: Run chart-testing (lint)
run: ct lint --config .github/linters/ct.yaml

# - name: Create kind cluster
# uses: helm/[email protected]
# if: steps.list-changed.outputs.changed == 'true'

# - name: Run chart-testing (install)
# run: ct install --config .github/linters/ct.yaml
59 changes: 59 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Release Charts

on:
push:
branches:
- main
jobs:
release:
permissions:
contents: write # to push chart release and create a release (helm/chart-releaser-action)
packages: write # needed for ghcr access
id-token: write # needed for keyless signing

runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Fetch history
run: git fetch --prune --unshallow

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Set up Helm
uses: Azure/setup-helm@v4
with:
version: v3.16.2

- name: Add dependency chart repos
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami
- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_GENERATE_RELEASE_NOTES: true
CR_SKIP_EXISTING: true

# see https://github.com/helm/chart-releaser/issues/183
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push charts to GHCR
run: |
shopt -s nullglob
for pkg in .cr-release-packages/*; do
if [ -z "${pkg:-}" ]; then
break
fi
helm push "${pkg}" "oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/charts"
done
4 changes: 2 additions & 2 deletions wordpress/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: v2
name: wordpress
description: A Helm chart for Kubernetes
description: A Helm chart for Wordpress on Kubernetes with NGINX and PHP-FPM
type: application
version: 0.1.0
appVersion: "1.0.0"
appVersion: "6.2.2"
dependencies:
- name: mariadb
version: "19.1.0"
Expand Down
4 changes: 2 additions & 2 deletions wordpress/templates/wordpress-plugins-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ metadata:
{{- include "wordpress.labels" (dict "root" . "component" "plugins") | nindent 4 }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-weight": "-4"
"helm.sh/hook-delete-policy": hook-succeeded
"helm.sh/hook-weight": "-1"
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
spec:
template:
metadata:
Expand Down

0 comments on commit c6adfaa

Please sign in to comment.