55 pull_request :
66 types : [opened, synchronize, reopened, ready_for_review]
77 paths :
8- - " charts/**"
9- - " values/**"
10- - " tests/fixtures/**"
11- - " helmfile.d/**"
8+ - ' charts/**'
9+ - ' values/**'
10+ - ' tests/fixtures/**'
11+ - ' helmfile.d/**'
1212
1313permissions :
1414 contents : read
@@ -64,24 +64,25 @@ jobs:
6464 - name : Checkout PR branch
6565 uses : actions/checkout@v6
6666 with :
67- ref : ${{ github.event.pull_request.head.sha }}
67+ ref : ${{ github.event.pull_request.head.sha || github.sha }}
68+ fetch-depth : 0
6869 path : pr
69- - name : Checkout base branch
70- uses : actions/checkout@v6
71- with :
72- ref : ${{ github.event.pull_request.base.ref || 'main' }}
73- path : base
7470 - name : Set up Node.js
7571 uses : actions/setup-node@v6
7672 with :
7773 node-version-file : ' pr/.nvmrc'
7874 check-latest : true
7975 - name : Install npm dependencies
80- run : cd "$GITHUB_WORKSPACE/pr" && npm install --no-save && cd "$GITHUB_WORKSPACE/base" && npm install --no-save
76+ run : cd "$GITHUB_WORKSPACE/pr" && npm install --no-save
77+ - name : Prepare base branch ref for worktree
78+ run : |
79+ cd "$GITHUB_WORKSPACE/pr"
80+ base_ref="${{ github.event.pull_request.base.ref || 'main' }}"
81+ git fetch --no-tags --prune origin "$base_ref:$base_ref"
8182 - name : Install Helm and Helmfile
8283 uses : helmfile/helmfile-action@v2.4.6
8384 with :
84- helmfile-args : version # In this step, we only want these tools to be installed
85+ helmfile-args : version # In this step, we only want these tools to be installed
8586 helm-plugins : >
8687 https://github.com/databus23/helm-diff,
8788 https://github.com/jkroepke/helm-secrets
@@ -96,12 +97,16 @@ jobs:
9697 id : run_script
9798 env :
9899 GH_TOKEN : ${{ secrets.BOT_TOKEN }}
100+ HUSKY : ' 0'
99101 run : |
102+ cd "$GITHUB_WORKSPACE/pr"
100103 mkdir -p tmp
101- "$GITHUB_WORKSPACE/pr/ bin/compare.sh" "$GITHUB_WORKSPACE/base" "$GITHUB_WORKSPACE/pr" --diff-output tmp/diff-output.txt
102- comment_file="$PWD /tmp/pr-comment.txt"
104+ ./ bin/compare.sh --diff-output tmp/diff-output.txt
105+ comment_file="$GITHUB_WORKSPACE/pr /tmp/pr-comment.txt"
103106 echo "Comparison of Helm chart templating output:" > "$comment_file"
104107 echo '```diff' >> "$comment_file"
105- cat tmp/diff-output.txt >> "$comment_file"
108+ cat "$GITHUB_WORKSPACE/pr/ tmp/diff-output.txt" >> "$comment_file"
106109 echo '```' >> "$comment_file"
107- cd "$GITHUB_WORKSPACE/pr" && gh pr comment ${{ github.event.pull_request.number }} --body-file "$comment_file" --create-if-none --edit-last
110+ if [ "${{ github.event_name }}" = "pull_request" ]; then
111+ gh pr comment ${{ github.event.pull_request.number }} --body-file "$comment_file" --create-if-none --edit-last
112+ fi
0 commit comments