File tree Expand file tree Collapse file tree 1 file changed +28
-4
lines changed
Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Original file line number Diff line number Diff line change 123123 ${ build }
124124 build
125125
126- KUBECTL_EXTERNAL_DIFF="icdiff -N -r"
127- export KUBECTL_EXTERNAL_DIFF
128-
129126 diff() {
130127 kubectl diff ${
131128 if usesKustomize
134131 } "$manifest_path";
135132 }
136133
137- diff
134+ # GitHub case
135+ if [[ -v CI ]] && [[ -v BRANCH ]] && [[ -v OWNER_AND_REPO ]] && command gh > /dev/null ; then
136+
137+ set +e # diff exits 1 if diff existed
138+ read -r -d "" DIFFSTREAM <<DIFF
139+ ## Standard DiffPost
140+
141+ This PR would generate the following \`kubectl\` diff:
142+
143+ <details><summary>Preview</summary>
144+
145+ \`\`\`diff
146+ $(diff)
147+ \`\`\`
148+
149+ </details>
150+ DIFF
151+ set -e # we're past the invocation of diff
152+
153+ if ! gh pr --repo "$OWNER_AND_REPO" comment "$BRANCH" --edit-last -b "$DIFFSTREAM"; then
154+ echo "Make a first post ..."
155+ gh pr --repo "$OWNER_AND_REPO" comment "$BRANCH" -b "$DIFFSTREAM"
156+ fi
157+ else
158+ KUBECTL_EXTERNAL_DIFF="icdiff -N -r"
159+ export KUBECTL_EXTERNAL_DIFF
160+ diff
161+ fi
138162 '' { } )
139163 ( mkCommand currentSystem "apply" "Apply the manifests to K8s" [ pkgs . kubectl pkgs . icdiff ] ''
140164 ${ build }
You can’t perform that action at this time.
0 commit comments