-
Notifications
You must be signed in to change notification settings - Fork 88
94 lines (81 loc) · 2.65 KB
/
diff-hr-on-pr.yaml
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
---
name: "HelmRelease Diff"
on:
pull_request:
branches: ["master"]
paths: ["**.yaml"]
env:
KUBERNETES_DIR: ./
jobs:
changed-files:
name: Detect File Changes
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
json: true
files: |
**/*.yaml
files_ignore: |
.github/**
flux-system/**
Taskfile.yml
- id: set-matrix
run: echo "matrix={\"file\":${{ steps.changed-files.outputs.all_changed_files }}}" >> "${GITHUB_OUTPUT}"
diff:
name: Diff on Helm Releases
runs-on: ubuntu-latest
needs: [changed-files]
strategy:
matrix: ${{ fromJSON(needs.changed-files.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout default branch
uses: actions/checkout@v4
with:
ref: "${{ github.event.repository.default_branch }}"
path: default_branch
- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Setup Tools
run: |
brew install helm homeport/tap/dyff kustomize yq
- name: Diff
id: diff
run: |
# pin to 8.1.3 due to https://github.com/google/zx/issues/870
npm install [email protected]
diff=$(npx [email protected] ./.github/scripts/helmReleaseDiff.mjs \
--current-release "default_branch/${{ matrix.file }}" \
--incoming-release "${{ matrix.file }}" \
--kubernetes-dir ${{ env.KUBERNETES_DIR }} \
--diff-tool "diff")
echo "diff<<EOF" >> "${GITHUB_OUTPUT}"
echo "${diff}" >> "${GITHUB_OUTPUT}"
echo "EOF" >> "${GITHUB_OUTPUT}"
- name: Find Comment
if: ${{ always() && steps.diff.outputs.diff != '' }}
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: "Helm Release Diff: ${{ matrix.file }}"
- name: Create or update comment
if: ${{ always() && steps.diff.outputs.diff != '' }}
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Helm Release Diff: `${{ matrix.file }}`
```diff
${{ steps.diff.outputs.diff }}
```
edit-mode: replace