forked from UnitTestBot/UTBotJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush_with_rebase.sh
More file actions
32 lines (24 loc) · 819 Bytes
/
push_with_rebase.sh
File metadata and controls
32 lines (24 loc) · 819 Bytes
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
#!/bin/sh
set -e
# inputs: target_branch, target_directory, github_token, message
AUTHOR_EMAIL='github-actions[bot]@users.noreply.github.com'
AUTHOR_NAME='github-actions[bot]'
INPUT_BRANCH=${target_branch:-GITHUB_REF_NAME}
INPUT_DIRECTORY=${target_directory:-'.'}
REPOSITORY=$GITHUB_REPOSITORY
echo "Push to branch $INPUT_BRANCH";
[ -z "${github_token}" ] && {
echo 'Missing input "github_token: ${{ secrets.GITHUB_TOKEN }}".';
exit 1;
};
cd "${INPUT_DIRECTORY}"
remote_repo="https://${GITHUB_ACTOR}:${github_token}@github.com/${REPOSITORY}.git"
git config http.sslVerify false
git config --local user.email "${AUTHOR_EMAIL}"
git config --local user.name "${AUTHOR_NAME}"
git add -A
git commit -m "${message}"
until git push "${remote_repo}" HEAD:"${INPUT_BRANCH}"
do
git pull --rebase || exit 1
done