-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathentrypoint
executable file
·43 lines (30 loc) · 1.17 KB
/
entrypoint
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 -eux
CONFIG_ERROR=78
((jq -r ".comment.body" "${GITHUB_EVENT_PATH}" | grep -E "/submodules") \
&& jq -r ".issue.pull_request.url" "${GITHUB_EVENT_PATH}" \
) || exit ${CONFIG_ERROR}
if [ "$(jq -r ".action" "${GITHUB_EVENT_PATH}")" != "created" ]; then
echo "not a new comment"
exit ${CONFIG_ERROR}
fi
REPO=$(jq -r ".repository.full_name" "${GITHUB_EVENT_PATH}")
cd "${GITHUB_WORKSPACE}"
PR=$(jq -r ".issue.number" "${GITHUB_EVENT_PATH}")
BASE_URI="https://api.github.com"
API_HEADER="Accept: application/vnd.github.v3+json"
AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}"
PR_INFO=$(curl -X GET -s -H "${AUTH_HEADER}" -H "${API_HEADER}" \
"${BASE_URI}/repos/${REPO}/pulls/${PR}")
REF=$(echo "${PR_INFO}" | jq -r .head.ref)
git config --global user.email "[email protected]"
git config --global user.name "GitHub Submodules Action"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${REPO}.git
git fetch --all -p
git checkout "${REF}"
git submodule init
git submodule update
git submodule foreach 'git fetch --all -p'
git submodule foreach 'git merge origin/master'
git add -v .
git commit -m "bumping submodules"
git push origin "${REF}"