Skip to content

Commit 00ed15d

Browse files
committed
try diffoscope
1 parent 5bc6520 commit 00ed15d

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ jobs:
1919
kustomizations: |-
2020
testdata/prod
2121
testdata/stage
22-
- run: echo "${{ steps.test-action.outputs.diff }}"
2322
- uses: mshick/add-pr-comment@v2
2423
with:
25-
message: |
26-
```diff
27-
${{ steps.test-action.outputs.diff }}
28-
```
24+
message: ${{ steps.test-action.outputs.diff }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# GitHub Action for Kustomize Build+Diff
1+
# GitHub Action for Kustomize Build+Diff

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ inputs:
2323
default: ""
2424
outputs:
2525
diff:
26-
description: "Kustomize diff"
26+
description: "Kustomize diff in markdown"
2727
runs:
2828
using: "docker"
2929
image: "Dockerfile"

entrypoint.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,20 @@ git config --global --add safe.directory "$GITHUB_WORKSPACE"
2020
build "$INPUT_BASE_REF"
2121
build "$INPUT_HEAD_REF"
2222

23-
diffoscope "$build_dir/$INPUT_BASE_REF" "$build_dir/$INPUT_HEAD_REF" --markdown diff.md --exclude-directory-metadata=recursive || true
24-
output=$(cat diff.md)
23+
base_ref_build_dir="$build_dir/$INPUT_BASE_REF"
24+
head_ref_build_dir="$build_dir/$INPUT_HEAD_REF"
2525

26-
# If escaped output is longer than 65000 characters return "output to large to print as a github comment"
27-
if [ ${#output} -gt 65000 ]; then
28-
output="Output is greater than 65000 characters, and therefore too large to print as a github comment."
29-
fi
26+
set +e
27+
for target in $INPUT_KUSTOMIZATIONS; do
28+
diffoscope "$base_ref_build_dir/$target" "$head_ref_build_dir/$target" \
29+
--markdown - \
30+
--exclude-directory-metadata=yes | tee -a diff.md
31+
done
32+
33+
set -e
34+
35+
# Formatting hacks
36+
output=$(cat diff.md | sed "s|$base_ref_build_dir/||" | sed '/Comparing/ s/&.*$//' | sed "s|^#\{2,\} Comparing| Comparing|" | sed "s|^# Comparing|## Comparing|")
3037

3138
{
3239
echo 'diff<<EOF'

0 commit comments

Comments
 (0)