Skip to content

Commit 29fa0d6

Browse files
Create diff-envs.yml
1 parent 5e5a0ec commit 29fa0d6

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/diff-envs.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
on:
2+
pull_request:
3+
types: [opened, synchronize]
4+
5+
permissions:
6+
contents: read
7+
pull-requests: write
8+
9+
name: Diff GitOps Environments
10+
11+
jobs:
12+
diff-env:
13+
# The type of runner that the job will run on
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout PR
18+
uses: actions/checkout@v3
19+
with:
20+
path: pr
21+
- name: Checkout Target of PR
22+
uses: actions/checkout@v3
23+
with:
24+
path: target
25+
ref: ${{ github.event.pull_request.base.ref }}
26+
27+
# - run: |
28+
# ls -la
29+
# ls -la pr
30+
# ls -la target
31+
# - run: diff pr/envs/qa/settings.yml target/envs/qa/settings.yml > changes2.diff || true
32+
- run: |
33+
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
34+
kustomize build pr/envs/qa/ > qa-pr.yml
35+
kustomize build target/envs/qa/ > qa-target.yml
36+
diff -U 7 qa-pr.yml qa-target.yml > qa-changes.diff || true
37+
kustomize build pr/envs/prod/ > prod-pr.yml
38+
kustomize build target/envs/prod/ > prod-target.yml
39+
diff -U 7 prod-pr.yml prod-target.yml > prod-changes.diff || true
40+
kustomize build pr/envs/staging/ > staging-pr.yml
41+
kustomize build target/envs/staging/ > staging-target.yml
42+
diff -U 7 staging-pr.yml staging-target.yml > staging-changes.diff || true
43+
- run: |
44+
wget https://raw.githubusercontent.com/kostis-codefresh/kustomize-github-preview-diff/main/pr-comment-template.txt
45+
sed 's/DESCRIPTION_HERE/QA-Changes/g' pr-comment-template.txt > qa-diff.txt
46+
sed -e "/DIFF_HERE/{r qa-changes.diff" -e "d}" qa-diff.txt > qa-result.txt
47+
sed 's/DESCRIPTION_HERE/Staging-Changes/g' pr-comment-template.txt > staging-diff.txt
48+
sed -e "/DIFF_HERE/{r staging-changes.diff" -e "d}" staging-diff.txt > staging-result.txt
49+
sed 's/DESCRIPTION_HERE/Prod-Changes/g' pr-comment-template.txt > prod-diff.txt
50+
sed -e "/DIFF_HERE/{r prod-changes.diff" -e "d}" prod-diff.txt > prod-result.txt
51+
cat qa-result.txt staging-result.txt prod-result.txt > comment.txt
52+
53+
54+
55+
- name: comment PR
56+
uses: machine-learning-apps/pr-comment@master
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
with:
60+
path: comment.txt

0 commit comments

Comments
 (0)