-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathentrypoint.sh
41 lines (28 loc) · 979 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
37
38
39
40
41
#!/usr/bin/env bash
set -x
UPSTREAM_REPO=$1
if [[ -z "$UPSTREAM_REPO" ]]; then
echo "Missing \$UPSTREAM_REPO"
exit 1
fi
if ! echo "$UPSTREAM_REPO" | grep '\.git'; then
UPSTREAM_REPO="https://github.com/${UPSTREAM_REPO_PATH}.git"
fi
echo "UPSTREAM_REPO=$UPSTREAM_REPO"
git clone "https://github.com/${GITHUB_REPOSITORY}.git" work
cd work || { echo "Missing work dir" && exit 2 ; }
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git remote set-url origin "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY_URL"
git remote add upstream "$UPSTREAM_REPO"
git fetch upstream
git remote -v
git checkout master
MERGE_RESULT=$(git merge upstream/master)
if [[ $MERGE_RESULT != *"Already up to date."* ]]; then
git commit -m "Merged upstream"
git push origin master
fi
cd ..
rm -rf work