forked from Drewsif/PiShrink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgha-wrapper-pishrink.sh
executable file
·49 lines (46 loc) · 1.33 KB
/
gha-wrapper-pishrink.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
#!/bin/bash -eu
action_root="$(dirname "$(realpath "$BASH_SOURCE")")"
flags=""
destination=""
case "$INPUT_COMPRESS" in
gzip | gz)
flags="$flags -z"
if [ ! -z "$INPUT_DESTINATION" ]; then
destination="$(echo "$INPUT_DESTINATION" | sed -e 's~\.gz$~~')"
echo "destination=$destination.gz" >> $GITHUB_OUTPUT
else
echo "destination=$INPUT_IMAGE.gz" >> $GITHUB_OUTPUT
fi
;;
xz)
flags="$flags -Z"
if [ ! -z "$INPUT_DESTINATION" ]; then
destination="$(echo "$INPUT_DESTINATION" | sed -e 's~\.xz$~~')"
echo "destination=$destination.xz" >> $GITHUB_OUTPUT
else
echo "destination=$INPUT_IMAGE.xz" >> $GITHUB_OUTPUT
fi
;;
none | "false" | "")
echo "destination=$INPUT_DESTINATION" >> $GITHUB_OUTPUT
;;
*)
echo "Error: unrecognized compression type: $INPUT_COMPRESS"
exit 1
;;
esac
if [ "$INPUT_COMPRESS_PARALLEL" == "true" ]; then
flags="$flags -a"
fi
if [ "$INPUT_PREVENT_EXPANSION" == "true" ]; then
flags="$flags -s"
fi
if [ "$INPUT_ADVANCED_FS_REPAIR" == "true" ]; then
flags="$flags -r"
fi
if [ "$INPUT_VERBOSE" == "true" ]; then
flags="$flags -v"
fi
echo "Running pishrink.sh $flags \"$INPUT_IMAGE\" \"$destination\"..."
sudo --preserve-env=PISHRINK_GZIP --preserve-env=PISHRINK_XZ \
"$action_root/pishrink.sh" $flags "$INPUT_IMAGE" "$destination"