-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathentrypoint.sh
executable file
·43 lines (33 loc) · 1.23 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
#!/bin/sh
git config --global --add safe.directory /github/workspace
if case $INPUT_DIRECTORY in "/"*) ;; *) false;; esac; then
git config --global --add safe.directory "$INPUT_DIRECTORY"
else
git config --global --add safe.directory "/github/workspace/$INPUT_DIRECTORY"
fi
cd "$INPUT_DIRECTORY" || exit 1
CURRENT_BRANCH=$(echo "$GITHUB_REF" | sed "s@refs/heads/@@")
TARGET_BRANCH=$INPUT_BRANCH
case $TARGET_BRANCH in "refs/heads/"*)
TARGET_BRANCH=$(echo "$TARGET_BRANCH" | sed "s@refs/heads/@@")
esac
if [ "$INPUT_FORCE" != "0" ]; then
FORCE='--force'
fi
echo "machine github.com" > "$HOME/.netrc"
echo " login $GITHUB_ACTOR" >> "$HOME/.netrc"
echo " password $INPUT_TOKEN" >> "$HOME/.netrc"
echo "machine api.github.com" >> "$HOME/.netrc"
echo " login $GITHUB_ACTOR" >> "$HOME/.netrc"
echo " password $INPUT_TOKEN" >> "$HOME/.netrc"
git config user.email "$INPUT_EMAIL"
git config user.name "$INPUT_NAME"
# shellcheck disable=SC2086
git add $INPUT_FILES -v
git commit -m "$INPUT_MESSAGE"
git branch actions-x-temp-branch
git fetch "$INPUT_REPOSITORY" "$CURRENT_BRANCH"
git checkout "$CURRENT_BRANCH"
git merge actions-x-temp-branch
git branch -d actions-x-temp-branch
git push "$INPUT_REPOSITORY" "$CURRENT_BRANCH:$TARGET_BRANCH" $FORCE