-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·32 lines (25 loc) · 1022 Bytes
/
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
#!/usr/bin/env sh
set -e
set -x
if [ $# -ne 4 ]; then
echo "Error: Invalid number of arguments."
exit 1
fi
prefix=$1
remote=$2
reference=$3
as_tag=$4
# Convert the remote URL to use the https protocol and include the GITHUB_TOKEN for authentication
remote_https=$(echo "$remote" | sed 's/^git@github.com:/https:\/\/github.com\//' | sed "s/^https:\/\/github.com\//https:\/\/${GITHUB_TOKEN}@github.com\//")
# Set necessary git configuration options
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config --local --unset-all http.https://github.com/.extraheader # https://github.com/actions/checkout/issues/162#issuecomment-590821598
# Split the repository
git remote add splitsh_target_remote "$remote_https"
SHA1=`/usr/local/bin/splitsh-lite --prefix="$prefix"`
# Push the split repository to the remote
if [ "$as_tag" = "true" ]; then
git push splitsh_target_remote "$SHA1:refs/tags/$reference" -f --verbose
else
git push splitsh_target_remote "$SHA1:refs/heads/$reference" -f --verbose
fi