-
Notifications
You must be signed in to change notification settings - Fork 33
/
entrypoint.sh
executable file
·44 lines (36 loc) · 1.04 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
#!/bin/sh -l
git_setup() {
cat <<- EOF > $HOME/.netrc
machine github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
machine api.github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
EOF
chmod 600 $HOME/.netrc
git config --global user.email "$GITBOT_EMAIL"
git config --global user.name "$GITHUB_ACTOR"
git config --global --add safe.directory /github/workspace
}
git_cmd() {
if [[ "${DRY_RUN:-false}" == "true" ]]; then
echo $@
else
eval $@
fi
}
git_setup
PR_BRANCH="auto-$INPUT_PR_BRANCH-$GITHUB_SHA"
MESSAGE=$(git log -1 $GITHUB_SHA | grep "AUTO" | wc -l)
if [[ $MESSAGE -gt 0 ]]; then
echo "Autocommit, NO ACTION"
exit 0
fi
PR_TITLE=$(git log -1 --format="%s" ${GITHUB_SHA})
git_cmd git remote update
git_cmd git fetch --all
git_cmd git checkout -b "${PR_BRANCH}" origin/"${INPUT_PR_BRANCH}"
git_cmd git cherry-pick "${GITHUB_SHA}"
git_cmd git push -u origin "${PR_BRANCH}"
git_cmd hub pull-request -b "${INPUT_PR_BRANCH}" -h "${PR_BRANCH}" -l "${INPUT_PR_LABELS}" -a "${GITHUB_ACTOR}" -m "\"AUTO: ${PR_TITLE}\""