-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·76 lines (68 loc) · 1.48 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
#!/bin/sh -l
# Initialize variables
format=""
action=""
repository=""
branch=""
extra_args=""
github_token=""
working_directory=""
cache_dir="/tmp/.cache"
# Parse the named arguments
while [ "$#" -gt 0 ]; do
case "$1" in
--format)
format="$2"
shift 2
;;
--action)
action="$2"
shift 2
;;
--branch)
branch="$2"
shift 2
;;
--repository)
repository="$2"
shift 2
;;
--extra_args)
extra_args="$2"
shift 2
;;
# other arguments ...
--github_token)
github_token="$2"
shift 2
;;
--working_directory)
working_directory="$2"
shift 2
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done
cd "$working_directory" || exit
# Set the cache directory to a writable path
export XDG_CACHE_HOME="$cache_dir"
mkdir -p "$XDG_CACHE_HOME"
# If $repository is empty, use the current repository
if [ -z "$repository" ]; then
repository="$GITHUB_REPOSITORY"
fi
# If $github_token is not empty, override the built-in token
if [ -n "$github_token" ]; then
export GITHUB_TOKEN="$github_token"
fi
# Run the lastversion command with the given inputs
if [ -z "$branch" ]; then
result=$(lastversion $extra_args --format "$format" "$action" "$repository")
else
result=$(lastversion $extra_args --branch "$branch" --format "$format" "$action" "$repository")
fi
# Set the result as an output variable
echo "last_version=${result}" >> "$GITHUB_OUTPUT"