@@ -22,15 +22,21 @@ start() {
2222 say Launching runner with run.sh ...
2323 line
2424 cd $RUNNER_FOLDER
25- ./run.sh
25+
26+ # Run.sh in a new process.
27+ ./run.sh &
28+ RUNNER_PID=$!
29+ say " Run.sh PID: $RUNNER_PID "
30+ wait $RUNNER_PID
31+
2632 else
2733 say Launching runner with run.sh ... SKIPPED.
2834 say Exiting github-runner.
2935 fi
3036
3137}
3238welcome () {
33- say " GitHub Runner | ${RUNNER_SCRIPT_PATH} "
39+ say " GitHub Runner"
3440 say Welcome! This script will:
3541 say 1. Install Runner
3642 say 2. Configure Runner
@@ -67,11 +73,17 @@ verify() {
6773 RUNNER_SCRIPT_ENV_FILE_STATUS=" (Not found)"
6874 fi
6975
70- # Detect composer usage.
76+ # Detect path to this script.
77+ # @TODO: Rename RUNNER_SCRIPT_ to reduce confusion with github runner CLI
7178 if [[ -z " $COMPOSER_RUNTIME_BIN_DIR " ]]; then
72- RUNNER_SCRIPT_PATH=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
79+ RUNNER_SCRIPT_PATH=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) /github-runner "
7380 else
74- RUNNER_SCRIPT_PATH=" $COMPOSER_RUNTIME_BIN_DIR "
81+ RUNNER_SCRIPT_PATH=" $COMPOSER_RUNTIME_BIN_DIR /github-runner"
82+ fi
83+ if [[ ! -f " ${RUNNER_SCRIPT_PATH} " ]]; then
84+ say " Path detection failed."
85+ say " No file found at ${RUNNER_SCRIPT_PATH} "
86+ exit 1
7587 fi
7688 RUNNER_SCRIPT_DIR=$( dirname $RUNNER_SCRIPT_PATH )
7789
@@ -140,27 +152,35 @@ verify() {
140152 line
141153 welcome
142154
143- if [[ -z " ${GITHUB_REPOSITORY} " ]]; then
144- line
145- say GITHUB_REPOSITORY is required. Use --repo or set the environment variable.
146- exit 1
147- fi
148-
149- # Add name to labels.
150- RUNNER_CONFIG_LABELS=" ${RUNNER_CONFIG_LABELS} ,${RUNNER_CONFIG_NAME} "
151-
152- # Gather API token to create runners.
153- if [[ -z " ${GITHUB_TOKEN} " ]]; then
154- line
155- say GITHUB_TOKEN is required. Use --token or set the environment variable.
156- say Create a ' Personal Access Token' owned by the organization, with ' admin:write' access on this repository
157- say https://github.com/settings/personal-access-tokens/new
158- line
159- exit 1
155+ if [[ -n " ${RUNNER_CONFIG} " ]]; then
156+ if [[ -z " ${GITHUB_REPOSITORY} " ]]; then
157+ line
158+ say GITHUB_REPOSITORY is required. Use --repo or set the environment variable.
159+ exit 1
160+ fi
161+
162+ # Add name to labels.
163+ RUNNER_CONFIG_LABELS=" ${RUNNER_CONFIG_LABELS} ,${RUNNER_CONFIG_NAME} "
164+
165+ # Gather API token to create runners.
166+ if [[ -z " ${GITHUB_TOKEN} " ]]; then
167+ line
168+ say GITHUB_TOKEN is required. Use --token or set the environment variable.
169+ say Create a ' Personal Access Token' owned by the organization, with ' admin:write' access on this repository
170+ say https://github.com/settings/personal-access-tokens/new
171+ line
172+ exit 1
173+ fi
160174 fi
161175
162176 # Prepare runner dir.
163177 line
178+ say " User: $( whoami) "
179+ say " Host: $( hostname -f) "
180+ say " Current directory: $( pwd) "
181+ say " Runner download path: $RUNNER_PATH "
182+ line
183+
164184 if [[ ! -d $RUNNER_PATH ]]; then
165185 mkdir -p $RUNNER_PATH
166186 RUNNER_FOLDER=$( realpath $RUNNER_PATH )
@@ -170,6 +190,9 @@ verify() {
170190 say Found folder: $RUNNER_FOLDER
171191 fi
172192
193+ line
194+ info
195+
173196 # getNewToken.
174197 line
175198 RESPONSE=$( curl -L \
@@ -248,13 +271,15 @@ configure() {
248271}
249272
250273stop () {
251- say " Stopped."
274+ say " Stopped. Run.sh PID: $RUNNER_PID "
275+ kill $RUNNER_PID
252276 ./config.sh remove --token ${RUNNER_CONFIG_TOKEN} || say " config remove didn't work."
253277
254278 exit 0
255279}
256280cancel () {
257- echo
281+ say " Cancelled. Run.sh PID: $RUNNER_PID "
282+ kill $RUNNER_PID
258283 if [[ " ${RUNNER_CLEANUP} " == " yes" ]]; then
259284 say " Cancelled. Removing $RUNNER_FOLDER ..."
260285 rm -rf $RUNNER_FOLDER
0 commit comments