-
Notifications
You must be signed in to change notification settings - Fork 3.6k
135 lines (117 loc) · 4.61 KB
/
helm-diff-ci.yml
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
---
name: Helm Loki Diff CI
on:
pull_request:
paths:
- "production/helm/loki/**"
# These permissions are needed to assume roles from Github's OIDC.
permissions:
contents: read
pull-requests: write
jobs:
helm-diff:
name: ${{ matrix.scenario.name }}
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
scenario:
- name: Single Binary Scenario
values_file: default-single-binary-values.yaml
use_k3d: true
- name: Default Values Scenario
values_file: default-values.yaml
use_k3d: true
- name: Ingress Values Scenario
values_file: ingress-values.yaml
use_k3d: true
- name: Legacy Monitoring Values Scenario
values_file: legacy-monitoring-values.yaml
use_k3d: true
- name: Simple Scalable AWS Kube IRSA Values Scenario
values_file: simple-scalable-aws-kube-irsa-values.yaml
use_k3d: false
- name: Simple Thanos Values Scenario
values_file: simple-thanos-values.yaml
use_k3d: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Helm
uses: azure/setup-helm@v4
- name: Add required Helm repositories
run: |
helm repo add minio https://charts.min.io/
helm repo add grafana https://grafana.github.io/helm-charts
helm repo add grafana-operator https://grafana.github.io/helm-charts
helm repo update
- name: Setup K3D
if: ${{ matrix.scenario.use_k3d }}
uses: ./.github/actions/setup-k3d
- name: Setup Helm plugins
if: ${{ matrix.scenario.use_k3d }}
run: |
helm plugin install https://github.com/databus23/helm-diff
- name: Build helm dependencies
run: |
helm dependency build production/helm/loki
# Conditional steps based on whether K3D is used
- name: Run diff with K3D
if: ${{ matrix.scenario.use_k3d }}
env:
HELM_DIFF_USE_UPGRADE_DRY_RUN: true
run: |
helm install --create-namespace loki-release grafana/loki -f production/helm/loki/scenarios/${{ matrix.scenario.values_file }}
helm diff upgrade loki-release -f production/helm/loki/scenarios/${{ matrix.scenario.values_file }} production/helm/loki | tee helm_diff_output.txt
- name: Run diff without K3D
if: ${{ !matrix.scenario.use_k3d }}
run: |
helm template loki-release grafana/loki -f production/helm/loki/scenarios/${{ matrix.scenario.values_file }} > release-manifest.yaml
helm template loki-release production/helm/loki -f production/helm/loki/scenarios/${{ matrix.scenario.values_file }} > current-manifest.yaml
diff current-manifest.yaml release-manifest.yaml > helm_diff_output.txt || true
- name: Convert Helm Diff Output to Markdown
id: convert_diff
run: |
cat helm_diff_output.txt >> formatted_diff_output.md
- name: Upload diff output as artifact
uses: actions/upload-artifact@v4
id: upload_diff
with:
name: ${{ matrix.scenario.name }}-diff-output
path: formatted_diff_output.md
retention-days: 2
summary-diff-outputs:
name: Summary Diffs
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.fork == false
needs: [helm-diff]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/download-artifact@v4
- name: Combine diff outputs
run: |
echo "## Helm Diff Output - Summary" > formatted_diff_output.md
for scenario in */formatted_diff_output.md; do
scenario_name=$(dirname "$scenario")
echo "<details>" >> formatted_diff_output.md
echo "" >> formatted_diff_output.md
echo "<summary>${scenario_name}</summary>" >> formatted_diff_output.md
echo "" >> formatted_diff_output.md
echo '```diff' >> formatted_diff_output.md
cat "$scenario" >> formatted_diff_output.md
echo '```' >> formatted_diff_output.md
echo "</details>" >> formatted_diff_output.md
echo "" >> formatted_diff_output.md
done
- name: Post diff as PR comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: "Helm Diff Output - Summary"
skip_unchanged: true
hide_and_recreate: true
append: true
hide_classify: "OUTDATED"
path: formatted_diff_output.md