Skip to content

Commit 4e4a0a3

Browse files
committed
feat: runner timeout
1 parent f4dc8b4 commit 4e4a0a3

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

.github/workflows/run-task.yml .github/workflows/setup-runners.yml

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
name: Run ECS Fargate Github Action Runner task(s)
2-
31
on:
42
workflow_call:
53
inputs:
64
cpu:
75
description: 'Amount of CPU units to allocate to a single task'
86
type: string
9-
required: true
107
default: '512'
118
memory:
129
description: 'Amount of memory (MB) to allocate to a single task'
@@ -15,22 +12,23 @@ on:
1512
labels:
1613
description: 'Coma-separated list of labels to assign to the tasks'
1714
type: string
18-
required: true
1915
default: ''
2016
count:
2117
description: 'Number of tasks to run'
2218
type: string
23-
required: true
2419
default: '1'
20+
timeout:
21+
description: 'Runner timeout'
22+
type: string
23+
default: '30m'
2524
secrets:
2625
TF_API_TOKEN:
2726
required: true
2827
GITHUB_PAT:
2928
required: true
3029

3130
jobs:
32-
run-task:
33-
name: Run ECS task
31+
setup-runners:
3432
runs-on: ubuntu-latest
3533
steps:
3634
- name: Generate runner token
@@ -71,7 +69,7 @@ jobs:
7169
echo 'run_task=true' >> .auto.tfvars
7270
echo 'cpu=${{ inputs.cpu }}' >> .auto.tfvars
7371
echo 'memory=${{ inputs.memory }}' >> .auto.tfvars
74-
echo 'runner_token="${{ steps.gen-token.outputs.result }}"' >> .auto.tfvars
72+
echo 'runner_token="::add-mask::${{ steps.gen-token.outputs.result }}"' >> .auto.tfvars
7573
echo 'repo_url="https://github.com/${{ github.repository }}"' >> .auto.tfvars
7674
echo 'labels="${{ inputs.labels }}"' >> .auto.tfvars
7775
echo 'desired_count=${{ inputs.count }}' >> .auto.tfvars

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ FROM myoung34/github-runner:ubuntu-focal
33
# modify actions runner binaries to allow custom cache server implementation
44
# https://gha-cache-server.falcondev.io/getting-started
55
RUN sed -i 's/\x41\x00\x43\x00\x54\x00\x49\x00\x4F\x00\x4E\x00\x53\x00\x5F\x00\x43\x00\x41\x00\x43\x00\x48\x00\x45\x00\x5F\x00\x55\x00\x52\x00\x4C\x00/\x41\x00\x43\x00\x54\x00\x49\x00\x4F\x00\x4E\x00\x53\x00\x5F\x00\x43\x00\x41\x00\x43\x00\x48\x00\x45\x00\x5F\x00\x4F\x00\x52\x00\x4C\x00/g' /actions-runner/bin/Runner.Worker.dll
6+
7+
CMD ["timeout", "$TIMEOUT", "./bin/Runner.Listener", "run", "--startuptype", "service"]

main.tf

+8-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ variable "desired_count" {
6161
default = null
6262
}
6363

64+
variable "timeout" {
65+
type = string
66+
default = null
67+
}
68+
6469
locals {
6570
availability_zone = "eu-central-1a"
6671
}
@@ -121,13 +126,14 @@ module "runner" {
121126
cache_url = module.cache-server.url
122127
}
123128

124-
module "run_task" {
129+
module "setup-runners" {
125130
count = var.run_task ? 1 : 0
126-
source = "./run_task"
131+
source = "./setup-runners"
127132
cpu = var.cpu
128133
memory = var.memory
129134
runner_token = var.runner_token
130135
repo_url = var.repo_url
131136
labels = var.labels
132137
desired_count = var.desired_count
138+
timeout = var.timeout
133139
}

run_task/main.tf setup-runners/main.tf

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ variable "desired_count" {
2222
type = number
2323
}
2424

25+
variable "timeout" {
26+
type = string
27+
}
28+
2529
data "aws_ecs_cluster" "this" {
2630
cluster_name = "github-actions-runner"
2731
}
@@ -76,6 +80,10 @@ data "aws_ecs_task_execution" "this" {
7680
key = "START_DOCKER_SERVICE"
7781
value = true
7882
}
83+
environment {
84+
key = "TIMEOUT"
85+
value = var.timeout
86+
}
7987
}
8088
}
8189
}

0 commit comments

Comments
 (0)