-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathentrypoint.sh
executable file
·56 lines (46 loc) · 1.43 KB
/
entrypoint.sh
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
#!/bin/sh
set -e
source $GITHUB_WORKSPACE/common/common.sh
readonly base="$1"
readonly revision="$2"
readonly format="$3"
readonly fail_on_diff="$4"
readonly include_path_params="$5"
readonly exclude_elements="$6"
readonly output_to_file="$7"
echo "running oasdiff diff base: $base, revision: $revision, format: $format, fail_on_diff: $fail_on_diff, include_path_params: $include_path_params, exclude_elements: $exclude_elements"
# Build flags to pass in command
flags=""
if [ "$format" != "yaml" ]; then
flags="$flags --format $format"
fi
if [ "$fail_on_diff" = "true" ]; then
flags="$flags --fail-on-diff"
fi
if [ "$include_path_params" = "true" ]; then
flags="$flags --include-path-params"
fi
if [ -n "$exclude_elements" ]; then
flags="$flags --exclude-elements $exclude_elements"
fi
echo "flags: $flags"
# *** github action step output ***
# output name should be in the syntax of multiple lines:
# {name}<<{delimiter}
# {value}
# {delimiter}
# see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
delimiter=$(cat /proc/sys/kernel/random/uuid | tr -d '-')
echo "diff<<$delimiter" >>"$GITHUB_OUTPUT"
set -o pipefail
if [ -n "$flags" ]; then
output=$(oasdiff diff "$base" "$revision" $flags)
else
output=$(oasdiff diff "$base" "$revision")
fi
if [ -n "$output" ]; then
write_output "$output"
else
write_output "No changes"
fi
echo "$delimiter" >>"$GITHUB_OUTPUT"