Skip to content

Commit 0273199

Browse files
authored
Merge pull request #34 from hexa2k9/feature-allow-dependabot-runners
Allow creating Dependabot Runners
2 parents daf4f42 + 5724f9d commit 0273199

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

app/clients/gcloud_client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ def create_runner_instance(self, registration_token, repo_url, template_name):
7474
"Skipping instance creation.")
7575
return None
7676

77-
instance_name = f"runner-{uuid.uuid4().hex[:16]}"
77+
instance_uuid = uuid.uuid4().hex[:16]
78+
if instance_template_resource.name.startswith("dependabot"):
79+
instance_name = f"dependabot-{instance_uuid}"
80+
else:
81+
instance_name = f"runner-{instance_uuid}"
82+
7883
logger.info(f"Creating GCE instance {instance_name} with template {instance_template_resource.self_link}")
7984

8085
# Set instance name

app/services/webhook_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def handle_workflow_job(self, payload):
6262
template_name = None
6363
if labels:
6464
for label in labels:
65-
if label.startswith('gcp-'):
65+
if label.startswith('gcp-') or label.lower() == 'dependabot':
6666
template_name = label
6767
break
6868
if template_name:

gcp/variables.tf

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ variable "github_runners_types" {
202202
}))
203203
# Similar to https://docs.github.com/en/enterprise-cloud@latest/actions/reference/runners/larger-runners
204204
default = [
205+
{
206+
name = "dependabot"
207+
instance_type = "e2-medium"
208+
vcpu = 2
209+
memory = 4
210+
disk_type = "pd-ssd"
211+
disk_size = 50
212+
disk_provisioned_iops = 0
213+
disk_provisioned_throughput = 0
214+
image = "ubuntu-2404-lts-amd64"
215+
arch = "amd64"
216+
},
205217
{
206218
name = "gcp-ubuntu-slim"
207219
instance_type = "e2-medium"
@@ -467,9 +479,9 @@ variable "github_runners_types" {
467479
validation {
468480
condition = alltrue([
469481
for config in var.github_runners_types :
470-
can(regex("^gcp-[a-zA-Z0-9-]+$", config.name))
482+
can(regex("(^dependabot$|^gcp-[a-zA-Z0-9-]+$)", config.name))
471483
])
472-
error_message = "All names must start with 'gcp-' and only contain letters, numbers and hyphens."
484+
error_message = "All names must start with 'gcp-' or must be named 'dependabot' and only contain letters, numbers and hyphens."
473485
}
474486

475487
validation {

0 commit comments

Comments
 (0)