this repo has no description
1---
2name: "Flux Diff"
3
4on:
5 pull_request:
6 branches: ["main"]
7 paths: ["k8s/**"]
8
9concurrency:
10 group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
11 cancel-in-progress: true
12
13jobs:
14 changed-clusters:
15 name: Changed Clusters
16 runs-on: ubuntu-latest
17 outputs:
18 matrix: ${{ steps.changed-clusters.outputs.all_changed_and_modified_files }}
19 steps:
20 - name: Generate Token
21 uses: actions/create-github-app-token@v3
22 id: app-token
23 with:
24 app-id: "${{ secrets.BOT_APP_ID }}"
25 private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"
26
27 - name: Checkout Default Branch
28 uses: actions/checkout@v6
29 with:
30 token: "${{ steps.app-token.outputs.token }}"
31 fetch-depth: 0
32
33 - name: Get Changed Clusters
34 id: changed-clusters
35 uses: tj-actions/changed-files@v47
36 with:
37 files: k8s/**
38 files_ignore: k8s/base/**
39 dir_names: true
40 dir_names_max_depth: 2
41 matrix: true
42
43 - name: List All Changed Clusters
44 run: echo "${{ steps.changed-clusters.outputs.all_changed_and_modified_files }}"
45
46 flux-diff:
47 name: Flux Diff
48 runs-on: ubuntu-latest
49 needs: ["changed-clusters"]
50 permissions:
51 pull-requests: write
52 strategy:
53 matrix:
54 paths: ${{ fromJSON(needs.changed-clusters.outputs.matrix) }}
55 resources: ["helmrelease", "kustomization"]
56 max-parallel: 4
57 fail-fast: false
58 steps:
59 - name: Generate Token
60 uses: actions/create-github-app-token@v3
61 id: app-token
62 with:
63 app-id: "${{ secrets.BOT_APP_ID }}"
64 private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"
65
66 - name: Checkout
67 uses: actions/checkout@v6
68 with:
69 token: "${{ steps.app-token.outputs.token }}"
70 path: pull
71
72 - name: Checkout Default Branch
73 uses: actions/checkout@v6
74 with:
75 token: "${{ steps.app-token.outputs.token }}"
76 ref: "${{ github.event.repository.default_branch }}"
77 path: default
78
79 - name: Diff Resources
80 uses: docker://ghcr.io/allenporter/flux-local:v8.2.0
81 with:
82 args: >-
83 diff ${{ matrix.resources }}
84 --unified 6
85 --path /github/workspace/pull/${{ matrix.paths }}/flux
86 --path-orig /github/workspace/default/${{ matrix.paths }}/flux
87 --strip-attrs "helm.sh/chart,checksum/config,app.kubernetes.io/version,chart"
88 --limit-bytes 10000
89 --all-namespaces
90 --sources "flux-system"
91 --output-file diff.patch
92
93 - name: Generate Diff
94 id: diff
95 run: |
96 cat diff.patch;
97 {
98 echo 'diff<<EOF'
99 cat diff.patch
100 echo EOF
101 } >> "$GITHUB_OUTPUT";
102 {
103 echo "### Diff"
104 echo '```diff'
105 cat diff.patch
106 echo '```'
107 } >> "$GITHUB_STEP_SUMMARY"
108
109 - if: ${{ steps.diff.outputs.diff != '' }}
110 name: Add comment
111 uses: mshick/add-pr-comment@v3
112 with:
113 repo-token: "${{ steps.app-token.outputs.token }}"
114 message-id: "${{ github.event.pull_request.number }}/${{ matrix.paths }}/${{ matrix.resources }}"
115 message-failure: Diff was not successful
116 message: |
117 ```diff
118 ${{ steps.diff.outputs.diff }}
119 ```
120
121 # Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7
122 flux-diff-success:
123 if: ${{ always() }}
124 needs: ["flux-diff"]
125 name: Flux Diff Successful
126 runs-on: ubuntu-latest
127 steps:
128 - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
129 name: Check matrix status
130 run: exit 1