This repository was archived by the owner on Sep 22, 2025. It is now read-only.
forked from actions/runner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
50 lines (38 loc) · 1.46 KB
/
entrypoint.sh
File metadata and controls
50 lines (38 loc) · 1.46 KB
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
45
46
47
48
49
50
#!/bin/sh
unset BUNDLE_PATH
unset BUNDLE_BIN
if [ -n "${ADDITIONAL_PACKAGES}" ]; then
TO_BE_INSTALLED=$(echo ${ADDITIONAL_PACKAGES} | tr "," " " )
echo "Installing additional packages: ${TO_BE_INSTALLED}"
sudo apt-get update && sudo apt-get install -y ${TO_BE_INSTALLED} && sudo apt-get clean
fi
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)
if [ -z "${RUNNER_NAME}" ]; then
RUNNER_NAME=$(hostname)
fi
./config.sh \
--name "${RUNNER_NAME}" \
--token "${RUNNER_TOKEN}" \
--url "${registration_url}" \
--work "${RUNNER_WORKDIR}" \
--labels "${RUNNER_LABELS}" \
--unattended \
--replace
remove() {
payload=$(curl -sX POST -H "Authorization: token ${GITHUB_PAT}" ${token_url%/registration-token}/remove-token)
export REMOVE_TOKEN=$(echo $payload | jq .token --raw-output)
./config.sh remove --unattended --token "${REMOVE_TOKEN}"
}
trap 'remove; exit 130' INT
trap 'remove; exit 143' TERM
./runsvc.sh "$*" &
wait $!