-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
119 lines (109 loc) · 3.89 KB
/
Copy pathaction.yml
File metadata and controls
119 lines (109 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: "Helm Chart Setup and Deployment"
description: "Setup a Helm chart, modify its appVersion, and deploy it to a Kubernetes cluster"
inputs:
helm-chart-version:
description: "The Helm chart version"
required: true
helm-registry-url:
description: "The Helm OCI registry URL"
required: true
helm-package:
description: "The Helm package"
required: true
helm-username:
description: "The username to authenticate with the Helm registry"
required: true
helm-password:
description: "The password to authenticate with the Helm registry"
required: true
helm-protocol:
description: "The protocol for fetching the Helm chart (e.g., oci://). Default is 'oci://'."
default: "oci://"
release-name:
description: "The name of the Helm release"
required: true
namespace:
description: "The namespace in which to deploy the Helm chart and application"
required: true
image-tag:
description: "Tag of the container image"
default: "latest"
working-directory:
description: "The working directory"
default: "."
values-file:
description: "Path to the Helm values file"
required: true
grafana-dashboards-folder:
description: "Folder containing Grafana dashboards"
default: "dashboards"
grafana-alerts-folder:
description: "Folder containing Grafana alerts"
default: "alerts"
timeout:
description: "Timeout for the Helm command"
default: "5m"
runs:
using: "composite"
steps:
- name: Login to Helm registry
shell: bash
run: |
helm registry login ${{ inputs.helm-registry-url }} \
-u ${{ inputs.helm-username }} \
-p ${{ inputs.helm-password }}
- name: Pull the Helm chart
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
helm pull ${{ inputs.helm-protocol }}${{ inputs.helm-registry-url }}/${{ inputs.helm-package }} \
--version ${{ inputs.helm-chart-version }}
- name: Extract Helm chart
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
tar -xzf ${{ inputs.helm-package }}-*.tgz
- name: Update appVersion in Chart.yaml
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
yq -i '.appVersion = "${{ github.sha }}" | .appVersion style="double"' \
${{ inputs.helm-package }}/Chart.yaml
- name: Collect Grafana dashboards and alerts
id: grafana-files
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
SET_FILE_ARGS=""
if [[ -d "${{ inputs.grafana-dashboards-folder }}" ]] && [[ "$(ls -A "${{ inputs.grafana-dashboards-folder }}")" ]]; then
i=0
for f in "${{ inputs.grafana-dashboards-folder }}"/*; do
if [[ -f "$f" ]]; then
SET_FILE_ARGS+=" --set-file grafana.dashboards[$i]=$f"
((i++))
fi
done
fi
if [[ -d "${{ inputs.grafana-alerts-folder }}" ]] && [[ "$(ls -A "${{ inputs.grafana-alerts-folder }}")" ]]; then
i=0
for f in "${{ inputs.grafana-alerts-folder }}"/*; do
if [[ -f "$f" ]]; then
SET_FILE_ARGS+=" --set-file grafana.alerts[$i]=$f"
((i++))
fi
done
fi
echo "set-file-args=$SET_FILE_ARGS" >> $GITHUB_OUTPUT
- name: Deploy Helm chart
shell: bash
working-directory: ${{ inputs.working-directory }}
env:
HELM_DRIVER: configmaps
run: |
helm upgrade --wait --install ${{ inputs.release-name }} ./${{ inputs.helm-package }} \
--history-max 10 \
--atomic --timeout ${{ inputs.timeout }} \
--set image.tag=${{ inputs.image-tag }} \
--namespace ${{ inputs.namespace }} \
--values ${{ inputs.values-file }} \
${{ steps.grafana-files.outputs.set-file-args }}