forked from karlludwigweise/git-subtree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
36 lines (28 loc) · 987 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
33
34
35
36
#!/bin/bash
# Function to handle errors
error_handler() {
echo "An error occurred. Exiting..."
exit 1
}
# Trap errors and call the error_handler function
trap 'error_handler' ERR
# Args
SQUASH=""
if [ "${INPUT_SQUASH}" == "true" ]; then
SQUASH="--squash"
fi
# Fix dubious ownership
git config --global --add safe.directory /github/workspace
# Set git email and name
git config --global user.email "${INPUT_GIT_EMAIL}"
git config --global user.name "${INPUT_GIT_NAME}"
# Make sure there are no prompts for git commands
cp .git/config .git/config-original
git config --global url."https://api:${INPUT_PAT}@github.com/".insteadOf "https://github.com/"
git config --unset http."https://github.com/".extraheader
# Update subtree
git subtree ${INPUT_ACTION} -d --prefix=${INPUT_PREFIX} "${INPUT_REPO}" "${INPUT_POSITION}" \
$([ "${INPUT_ACTION}" == "pull" ] && echo "--message='${INPUT_MESSAGE}'") \
$SQUASH
# Revert git config change
cp -f .git/config-original .git/config