Skip to content

Commit 2eccbc8

Browse files
kpturneresteve
authored andcommitted
Parameterise execution of runner
1 parent a8c20fc commit 2eccbc8

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ inputs:
8686
startup-timeout-seconds:
8787
description: >-
8888
Specifies the timeout in seconds to register the runner after the quiet period.
89+
run-runner-as-service:
90+
type: boolean
91+
description: >-
92+
Start the runner as a service rather than using ./run.sh as root.
8993
required: false
9094
outputs:
9195
label:

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
"dotenv": "^8.6.0",
2828
"eslint": "^7.32.0"
2929
}
30-
}
30+
}

src/aws.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ const config = require('./config');
55

66
// User data scripts are run as the root user
77
function buildUserDataScript(githubRegistrationToken, label) {
8+
let userData;
89
if (config.input.runnerHomeDir) {
910
// If runner home directory is specified, we expect the actions-runner software (and dependencies)
1011
// to be pre-installed in the AMI, so we simply cd into that directory and then start the runner
11-
return [
12+
userData = [
1213
'#!/bin/bash',
1314
`cd "${config.input.runnerHomeDir}"`,
1415
`echo "${config.input.preRunnerScript}" > pre-runner-script.sh`,
1516
'source pre-runner-script.sh',
1617
'export RUNNER_ALLOW_RUNASROOT=1',
1718
`./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label}`,
18-
'./run.sh',
1919
];
2020
} else {
21-
return [
21+
userData = [
2222
'#!/bin/bash',
2323
'mkdir actions-runner && cd actions-runner',
2424
`echo "${config.input.preRunnerScript}" > pre-runner-script.sh`,
@@ -28,9 +28,15 @@ function buildUserDataScript(githubRegistrationToken, label) {
2828
'tar xzf ./actions-runner-linux-${RUNNER_ARCH}-2.313.0.tar.gz',
2929
'export RUNNER_ALLOW_RUNASROOT=1',
3030
`./config.sh --url https://github.com/${config.githubContext.owner}/${config.githubContext.repo} --token ${githubRegistrationToken} --labels ${label}`,
31-
'./run.sh',
3231
];
3332
}
33+
if (config.input.runAsService) {
34+
userData.push('./svc.sh install');
35+
userData.push('./svc.sh start');
36+
} else {
37+
userData.push('./run.sh');
38+
}
39+
return userData;
3440
}
3541

3642
function buildMarketOptions() {

0 commit comments

Comments
 (0)