-
Notifications
You must be signed in to change notification settings - Fork 182
106 lines (100 loc) · 3.84 KB
/
svcaplbot-run-dyff.yml
File metadata and controls
106 lines (100 loc) · 3.84 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
name: chart-deps compare output to main
on:
workflow_dispatch: ~
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "charts/**"
- "values/**"
- "tests/fixtures/**"
- "helmfile.d/**"
permissions:
contents: read
jobs:
check-commit:
runs-on: ubuntu-latest
# Skip this pre-check check when triggered manually
if: github.event_name != 'workflow_dispatch'
outputs:
skip: ${{ steps.check.outputs.skip }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 2
- name: Check commit message and draft status
id: check
run: |
COMMIT_MSG=$(git log -1 --pretty=%B)
IS_DRAFT="${{ github.event.pull_request.draft }}"
EVENT_ACTION="${{ github.event.action }}"
echo "Commit message: $COMMIT_MSG"
echo "Is draft: $IS_DRAFT"
echo "Event action: $EVENT_ACTION"
if [[ $IS_DRAFT == "true" ]]; then
echo "Skipping - PR is in draft"
echo "skip=true" >> "$GITHUB_OUTPUT"
elif [[ $COMMIT_MSG == "Merge branch"* && $EVENT_ACTION != "ready_for_review" ]]; then
# Skip if merge commit, unless it is triggered by the ready_for_review event
echo "Skipping - merge commit"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "Running workflow"
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Show output
run: |
echo "Skip value: ${{ steps.check.outputs.skip }}"
run-compare:
runs-on: ubuntu-latest
needs: check-commit
if: ${{ github.event_name == 'workflow_dispatch' || (success() && needs.check-commit.outputs.skip != 'true') }}
steps:
- name: Install GitHub CLI
run: |
sudo apt update
sudo apt install gh -y
- name: Checkout PR branch
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
path: pr
- name: Checkout base branch
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.base.ref || 'main' }}
path: base
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: 'pr/.nvmrc'
- name: Install npm dependencies
run: cd "$GITHUB_WORKSPACE/pr" && npm install --no-save && cd "$GITHUB_WORKSPACE/base" && npm install --no-save
- name: Install Helm and Helmfile
uses: helmfile/helmfile-action@v2.4.1
with:
helmfile-args: version # In this step, we only want these tools to be installed
helm-plugins: >
https://github.com/databus23/helm-diff,
https://github.com/jkroepke/helm-secrets
- name: Install dyff
run: |
DYFF_VERSION="1.10.3"
wget https://github.com/homeport/dyff/releases/download/v${DYFF_VERSION}/dyff_${DYFF_VERSION}_linux_amd64.tar.gz
tar -xzf dyff_${DYFF_VERSION}_linux_amd64.tar.gz
sudo mv dyff /usr/local/bin/
dyff version
- name: Run compare script and add comment
id: run_script
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
mkdir -p tmp
"$GITHUB_WORKSPACE/pr/bin/compare.sh" "$GITHUB_WORKSPACE/base" "$GITHUB_WORKSPACE/pr" --diff-output tmp/diff-output.txt
comment_file="$PWD/tmp/pr-comment.txt"
echo "Comparison of Helm chart templating output:" > "$comment_file"
echo '```diff' >> "$comment_file"
cat tmp/diff-output.txt >> "$comment_file"
echo '```' >> "$comment_file"
cd "$GITHUB_WORKSPACE/pr" && gh pr comment ${{ github.event.pull_request.number }} --body-file "$comment_file" --create-if-none --edit-last