-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
entrypoint.sh
executable file
·92 lines (78 loc) · 2.56 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#! /bin/bash
# Create archive or exit if the command fails
set -eu
printf "\n📦 Creating %s archive...\n" "$INPUT_TYPE"
if [ -n "$INPUT_COMMAND" ]
then
eval $INPUT_COMMAND
fi
if [ "$INPUT_DIRECTORY" != "." ]
then
cd "$INPUT_DIRECTORY"
fi
if [ "$INPUT_TYPE" = "zip" ]
then
if [ "$RUNNER_OS" = "Windows" ]
then
if [ -z "$INPUT_EXCLUSIONS" ]
then
7z a -tzip "$INPUT_FILENAME" $INPUT_PATH $INPUT_CUSTOM || { printf "\n⛔ Unable to create %s archive.\n" "$INPUT_TYPE"; exit 1; }
else
EXCLUSIONS=''
for EXCLUSION in $INPUT_EXCLUSIONS
do
EXCLUSIONS+=" -x!"
EXCLUSIONS+=$EXCLUSION
done
for EXCLUSION in $INPUT_RECURSIVE_EXCLUSIONS
do
EXCLUSIONS+=" -xr!"
EXCLUSIONS+=$EXCLUSION
done
7z a -tzip "$INPUT_FILENAME" $INPUT_PATH $EXCLUSIONS $INPUT_CUSTOM || { printf "\n⛔ Unable to create %s archive.\n" "$INPUT_TYPE"; exit 1; }
fi
else
if [ -z "$INPUT_EXCLUSIONS" ]
then
zip -r "$INPUT_FILENAME" $INPUT_PATH $INPUT_CUSTOM || { printf "\n⛔ Unable to create %s archive.\n" "$INPUT_TYPE"; exit 1; }
else
zip -r "$INPUT_FILENAME" $INPUT_PATH -x $INPUT_EXCLUSIONS $INPUT_CUSTOM || { printf "\n⛔ Unable to create %s archive.\n" "$INPUT_TYPE"; exit 1; }
fi
fi
elif [ "$INPUT_TYPE" = "7z" ] || [ "$INPUT_TYPE" = "7zip" ]
then
if [ -z "$INPUT_EXCLUSIONS" ]
then
7z a -tzip "$INPUT_FILENAME" $INPUT_PATH $INPUT_CUSTOM || { printf "\n⛔ Unable to create %s archive.\n" "$INPUT_TYPE"; exit 1; }
else
EXCLUSIONS=''
for EXCLUSION in $INPUT_EXCLUSIONS
do
EXCLUSIONS+=" -x!"
EXCLUSIONS+=$EXCLUSION
done
for EXCLUSION in $INPUT_RECURSIVE_EXCLUSIONS
do
EXCLUSIONS+=" -xr!"
EXCLUSIONS+=$EXCLUSION
done
7z a -tzip "$INPUT_FILENAME" $INPUT_PATH $EXCLUSIONS $INPUT_CUSTOM || { printf "\n⛔ Unable to create %s archive.\n" "$INPUT_TYPE"; exit 1; }
fi
elif [ "$INPUT_TYPE" = "tar" ] || [ "$INPUT_TYPE" = "tar.gz" ]
then
if [ -z "$INPUT_EXCLUSIONS" ]
then
tar -zcvf "$INPUT_FILENAME" $INPUT_PATH $INPUT_CUSTOM || { printf "\n⛔ Unable to create %s archive.\n" "$INPUT_TYPE"; exit 1; }
else
EXCLUSIONS=''
for EXCLUSION in $INPUT_EXCLUSIONS
do
EXCLUSIONS+=" --exclude="
EXCLUSIONS+=$EXCLUSION
done
tar $EXCLUSIONS -zcvf "$INPUT_FILENAME" $INPUT_PATH $INPUT_CUSTOM || { printf "\n⛔ Unable to create %s archive.\n" "$INPUT_TYPE"; exit 1; }
fi
else
printf "\n⛔ Invalid archiving tool.\n"; exit 1;
fi
printf "\n✔ Successfully created %s archive.\n" "$INPUT_TYPE"