-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathentrypoint.sh
executable file
·67 lines (55 loc) · 1.79 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
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
set -e
write_output () {
local output="$1"
local truncate_if_needed="$2"
if [ -n "$output_to_file" ]; then
echo "$output" >> "$output-to-file"
fi
# github-action limits output to 1MB
# we count bytes because unicode has multibyte characters
if [ "$truncate_if_needed" = "true" ]; then
size=$(echo "$output" | wc -c)
if [ "$size" -ge "1000000" ]; then
echo "WARN: diff exceeds the 1MB limit, truncating output..." >&2
output=$(echo "$output" | head -c 1000000)
fi
fi
echo "$output" >>"$GITHUB_OUTPUT"
}
readonly base="$1"
readonly revision="$2"
readonly include_path_params="$3"
readonly exclude_elements="$4"
readonly output_to_file="$5"
echo "running oasdiff changelog base: $base, revision: $revision, include_path_params: $include_path_params, exclude_elements: $exclude_elements"
# Build flags to pass in command
flags=""
if [ "$include_path_params" = "true" ]; then
flags="${flags} --include-path-params"
fi
if [ "$exclude_elements" != "" ]; then
flags="${flags} --exclude-elements ${exclude_elements}"
fi
echo "flags: $flags"
set -o pipefail
# *** 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 '-')
write_output "changelog<<$delimiter"
if [ -n "$flags" ]; then
output=$(oasdiff changelog "$base" "$revision" "$flags")
else
output=$(oasdiff changelog "$base" "$revision")
fi
if [ -n "$output" ]; then
write_output "$output" "true"
else
write_output "No changelog changes"
fi
write_output "$delimiter"
# *** github action step output ***