forked from SanderKnape/github-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
33 lines (26 loc) · 929 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
#!/bin/sh
registration_url="https://github.com/${GITHUB_OWNER}"
if [ -z "${GITHUB_REPOSITORY}" ]; then
token_url="https://api.github.com/orgs/${GITHUB_OWNER}/actions/runners/registration-token"
else
token_url="https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPOSITORY}/actions/runners/registration-token"
registration_url="${registration_url}/${GITHUB_REPOSITORY}"
fi
echo "Requesting token at '${token_url}'"
payload=$(curl -sX POST -H "Authorization: token ${GITHUB_PAT}" ${token_url})
export RUNNER_TOKEN=$(echo $payload | jq .token --raw-output)
./config.sh \
--name $(hostname) \
--token ${RUNNER_TOKEN} \
--url ${registration_url} \
--work ${RUNNER_WORKDIR} \
--labels ${RUNNER_LABELS} \
--unattended \
--replace
remove() {
./config.sh remove --unattended --token "${RUNNER_TOKEN}"
}
trap 'remove; exit 130' INT
trap 'remove; exit 143' TERM
./run.sh "$*" &
wait $!