Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Enable runner updates by default #120

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/providers/codebuild.ts
Expand Up @@ -142,6 +142,9 @@ export class CodeBuildRunner extends Construct implements IRunnerProvider {
this.vpc = props.vpc;
this.securityGroup = props.securityGroup;

const disableRunnerUpdate = props.disableRunnerUpdate ?? true;
const disableUpdateFlag = disableRunnerUpdate ? '--disableupdate' : '';

let buildSpec = {
version: '0.2',
env: {
Expand All @@ -159,7 +162,7 @@ export class CodeBuildRunner extends Construct implements IRunnerProvider {
commands: [
'nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 &',
'timeout 15 sh -c "until docker info; do echo .; sleep 1; done"',
'sudo -Hu runner /home/runner/config.sh --unattended --url "https://${GITHUB_DOMAIN}/${OWNER}/${REPO}" --token "${RUNNER_TOKEN}" --ephemeral --work _work --labels "${RUNNER_LABEL}" --disableupdate --name "${RUNNER_NAME}"',
`sudo -Hu runner /home/runner/config.sh --unattended --url "https://$\{GITHUB_DOMAIN}/$\{OWNER}/$\{REPO}" --token "$\{RUNNER_TOKEN}" --ephemeral --work _work --labels "$\{RUNNER_LABEL}" ${disableUpdateFlag} --name "$\{RUNNER_NAME}"`,
],
},
build: {
Expand All @@ -178,7 +181,7 @@ export class CodeBuildRunner extends Construct implements IRunnerProvider {
if (image.os.is(Os.WINDOWS)) {
buildSpec.phases.install.commands = [
'cd \\actions',
'./config.cmd --unattended --url "https://${Env:GITHUB_DOMAIN}/${Env:OWNER}/${Env:REPO}" --token "${Env:RUNNER_TOKEN}" --ephemeral --work _work --labels "${Env:RUNNER_LABEL}" --disableupdate --name "${Env:RUNNER_NAME}"',
`./config.cmd --unattended --url "https://$\{Env:GITHUB_DOMAIN}/$\{Env:OWNER}/$\{Env:REPO}" --token "$\{Env:RUNNER_TOKEN}" --ephemeral --work _work --labels "$\{Env:RUNNER_LABEL}" ${disableUpdateFlag} --name "$\{Env:RUNNER_NAME}"`,
];
buildSpec.phases.build.commands = [
'cd \\actions',
Expand Down
7 changes: 7 additions & 0 deletions src/providers/common.ts
Expand Up @@ -147,6 +147,13 @@ export interface RunnerProviderProps {
* @default logs.RetentionDays.ONE_MONTH
*/
readonly logRetention?: logs.RetentionDays;

/**
* Whether to add the `--disableupdate` flag to the runner command.
*
* @default true
*/
readonly disableRunnerUpdate?: boolean;
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/providers/fargate.ts
Expand Up @@ -314,7 +314,7 @@ export class FargateRunner extends Construct implements IRunnerProvider {
}),
streamPrefix: 'runner',
}),
command: this.runCommand(),
command: this.runCommand(props.disableRunnerUpdate),
},
);

Expand Down Expand Up @@ -377,16 +377,17 @@ export class FargateRunner extends Construct implements IRunnerProvider {
);
}

private runCommand(): string[] {
private runCommand(disableRunnerUpdate: boolean = true): string[] {
const disableUpdateFlag = disableRunnerUpdate ? '--disableupdate' : '';
if (this.image.os.is(Os.LINUX)) {
return [
'sh', '-c',
'./config.sh --unattended --url "https://${GITHUB_DOMAIN}/${OWNER}/${REPO}" --token "${RUNNER_TOKEN}" --ephemeral --work _work --labels "${RUNNER_LABEL}" --disableupdate --name "${RUNNER_NAME}" && ./run.sh',
`./config.sh --unattended --url "https://$\{GITHUB_DOMAIN}/$\{OWNER}/$\{REPO}" --token "$\{RUNNER_TOKEN}" --ephemeral --work _work --labels "$\{RUNNER_LABEL}" ${disableUpdateFlag} --name "$\{RUNNER_NAME}" && ./run.sh`,
];
} else if (this.image.os.is(Os.WINDOWS)) {
return [
'powershell', '-Command',
'cd \\actions ; ./config.cmd --unattended --url "https://${Env:GITHUB_DOMAIN}/${Env:OWNER}/${Env:REPO}" --token "${Env:RUNNER_TOKEN}" --ephemeral --work _work --labels "${Env:RUNNER_LABEL}" --disableupdate --name "${Env:RUNNER_NAME}" ; ./run.cmd',
`cd \\actions ; ./config.cmd --unattended --url "https://$\{Env:GITHUB_DOMAIN}/$\{Env:OWNER}/$\{Env:REPO}" --token "$\{Env:RUNNER_TOKEN}" --ephemeral --work _work --labels "$\{Env:RUNNER_LABEL}" ${disableUpdateFlag} --name "$\{Env:RUNNER_NAME}" ; ./run.cmd`,
];
} else {
throw new Error(`Fargate runner doesn't support ${this.image.os.name}`);
Expand Down