Skip to content

Commit dd401f0

Browse files
committed
Add option to set github server url #303
1 parent 80104c3 commit dd401f0

File tree

11 files changed

+34
-10
lines changed

11 files changed

+34
-10
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ No requirements.
305305
| encrypt\_secrets | Encrypt secret variables for lambda's such as secrets and private keys. | `bool` | `true` | no |
306306
| environment | A name that identifies the environment, used as prefix and for tagging. | `string` | n/a | yes |
307307
| github\_app | GitHub app parameters, see your github app. Ensure the key is base64 encoded. | <pre>object({<br> key_base64 = string<br> id = string<br> client_id = string<br> client_secret = string<br> webhook_secret = string<br> })</pre> | n/a | yes |
308+
| github\_server\_url | (Optional) provide an alternative GitHub server url for GitHub on premise. | `string` | `"https://github.com/"` | no |
308309
| idle\_config | List of time period that can be defined as cron expression to keep a minimum amount of runners active instead of scaling down to 0. By defining this list you can ensure that in time periods that match the cron expression within 5 seconds a runner is kept idle. | <pre>list(object({<br> cron = string<br> timeZone = string<br> idleCount = number<br> }))</pre> | `[]` | no |
309310
| instance\_profile\_path | The path that will be added to the instance\_profile, if not set the environment name will be used. | `string` | `null` | no |
310311
| instance\_type | Instance type for the action runner. | `string` | `"m5.large"` | no |

main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ module "runners" {
7474
ami_filter = local.ami_filter
7575
ami_owners = var.ami_owners
7676

77+
github_server_url = var.github_server_url
7778
sqs_build_queue = aws_sqs_queue.queued_builds
7879
github_app = var.github_app
7980
enable_organization_runners = var.enable_organization_runners

modules/download-lambda/README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ No requirements.
3232
## Providers
3333

3434
| Name | Version |
35-
| ---- | ------- |
36-
| null | n/a |
35+
|------|---------|
36+
| null | n/a |
3737

3838
## Inputs
3939

40-
| Name | Description | Type | Default | Required |
41-
| ------- | ------------------------------------- | --------------------------------------------------------------------------- | ------- | :------: |
42-
| lambdas | Name and tag for lambdas to download. | <pre>list(object({<br> name = string<br> tag = string<br> }))</pre> | n/a | yes |
40+
| Name | Description | Type | Default | Required |
41+
|------|-------------|------|---------|:--------:|
42+
| lambdas | Name and tag for lambdas to download. | <pre>list(object({<br> name = string<br> tag = string<br> }))</pre> | n/a | yes |
4343

4444
## Outputs
4545

46-
| Name | Description |
47-
| ----- | ----------- |
48-
| files | n/a |
46+
| Name | Description |
47+
|------|-------------|
48+
| files | n/a |
4949

5050
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
5151

modules/runner-binaries-syncer/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ No requirements.
5151
| aws\_region | AWS region. | `string` | n/a | yes |
5252
| distribution\_bucket\_name | Bucket for storing the action runner distribution. | `string` | n/a | yes |
5353
| environment | A name that identifies the environment, used as prefix and for tagging. | `string` | n/a | yes |
54+
| lambda\_s3\_bucket | S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly. | `any` | `null` | no |
5455
| lambda\_schedule\_expression | Scheduler expression for action runner binary syncer. | `string` | `"cron(27 * * * ? *)"` | no |
5556
| lambda\_timeout | Time out of the lambda in seconds. | `number` | `300` | no |
5657
| lambda\_zip | File location of the lambda zip file. | `string` | `null` | no |
@@ -59,6 +60,8 @@ No requirements.
5960
| role\_permissions\_boundary | Permissions boundary that will be added to the created role for the lambda. | `string` | `null` | no |
6061
| runner\_allow\_prerelease\_binaries | Allow the runners to update to prerelease binaries. | `bool` | `false` | no |
6162
| runner\_architecture | The platform architecture for the runner instance (x64, arm64), defaults to 'x64' | `string` | `"x64"` | no |
63+
| syncer\_lambda\_s3\_key | S3 key for syncer lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no |
64+
| syncer\_lambda\_s3\_object\_version | S3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no |
6265
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
6366

6467
## Outputs

modules/runners/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ No requirements.
7272
| encryption | KMS key to encrypted lambda environment secrets. Either provide a key and `encrypt` set to `true`. Or set the key to `null` and encrypt to `false`. | <pre>object({<br> kms_key_id = string<br> encrypt = bool<br> })</pre> | n/a | yes |
7373
| environment | A name that identifies the environment, used as prefix and for tagging. | `string` | n/a | yes |
7474
| github\_app | GitHub app parameters, see your github app. Ensure the key is base64 encoded. | <pre>object({<br> key_base64 = string<br> id = string<br> client_id = string<br> client_secret = string<br> })</pre> | n/a | yes |
75+
| github\_server\_url | (Optional) provide an alternative GitHub server url for GitHub on premise. | `string` | `"https://github.com/"` | no |
7576
| idle\_config | List of time period that can be defined as cron expression to keep a minimum amount of runners active instead of scaling down to 0. By defining this list you can ensure that in time periods that match the cron expression within 5 seconds a runner is kept idle. | <pre>list(object({<br> cron = string<br> timeZone = string<br> idleCount = number<br> }))</pre> | `[]` | no |
7677
| instance\_profile\_path | The path that will be added to the instance\_profile, if not set the environment name will be used. | `string` | `null` | no |
7778
| instance\_type | Default instance type for the action runner. | `string` | `"m5.large"` | no |

modules/runners/lambdas/runners/src/scale-runners/scale-up.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe('scaleUp', () => {
3838
process.env.GITHUB_APP_CLIENT_SECRET = 'TEST_CLIENT_SECRET';
3939
process.env.RUNNERS_MAXIMUM_COUNT = '3';
4040
process.env.ENVIRONMENT = 'unit-test-environment';
41+
process.env.GITHUB_SERVER_URL = 'https://github.com/'
4142

4243
jest.clearAllMocks();
4344
mockOctokit.actions.listWorkflowRunsForRepo.mockImplementation(() => ({

modules/runners/lambdas/runners/src/scale-runners/scale-up.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const scaleUp = async (eventSource: string, payload: ActionRequestMessage
5656
const environment = process.env.ENVIRONMENT as string;
5757
const githubAppAuth = await createGithubAppAuth(payload.installationId);
5858
const githubInstallationClient = await createInstallationClient(githubAppAuth);
59+
const githubServerUrl = process.env.GITHUB_SERVER_URL as string;
5960
const queuedWorkflows = await githubInstallationClient.actions.listWorkflowRunsForRepo({
6061
owner: payload.repositoryOwner,
6162
repo: payload.repositoryName,
@@ -93,8 +94,8 @@ export const scaleUp = async (eventSource: string, payload: ActionRequestMessage
9394
await createRunner({
9495
environment: environment,
9596
runnerConfig: enableOrgLevel
96-
? `--url https://github.com/${payload.repositoryOwner} --token ${token} ${labelsArgument}`
97-
: `--url https://github.com/${payload.repositoryOwner}/${payload.repositoryName} --token ${token} ${labelsArgument}`,
97+
? `--url ${githubServerUrl}${payload.repositoryOwner} --token ${token} ${labelsArgument}`
98+
: `--url ${githubServerUrl}${payload.repositoryOwner}/${payload.repositoryName} --token ${token} ${labelsArgument}`,
9899
orgName: enableOrgLevel ? payload.repositoryOwner : undefined,
99100
repoName: enableOrgLevel ? undefined : `${payload.repositoryOwner}/${payload.repositoryName}`,
100101
});

modules/runners/scale-up.tf

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ resource "aws_lambda_function" "scale_up" {
3333
ENABLE_ORGANIZATION_RUNNERS = var.enable_organization_runners
3434
RUNNER_EXTRA_LABELS = var.runner_extra_labels
3535
RUNNERS_MAXIMUM_COUNT = var.runners_maximum_count
36+
GITHUB_SERVER_URL = var.github_server_url
3637
GITHUB_APP_KEY_BASE64 = local.github_app_key_base64
3738
GITHUB_APP_ID = var.github_app.id
3839
GITHUB_APP_CLIENT_ID = var.github_app.client_id

modules/runners/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,9 @@ variable "create_service_linked_role_spot" {
238238
type = bool
239239
default = false
240240
}
241+
242+
variable "github_server_url" {
243+
description = "(Optional) provide an alternative GitHub server url for GitHub on premise."
244+
type = string
245+
default = "https://github.com/"
246+
}

modules/webhook/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,16 @@ No requirements.
5252
| encryption | KMS key to encrypted lambda environment secrets. Either provide a key and `encrypt` set to `true`. Or set the key to `null` and encrypt to `false`. | <pre>object({<br> kms_key_id = string<br> encrypt = bool<br> })</pre> | n/a | yes |
5353
| environment | A name that identifies the environment, used as prefix and for tagging. | `string` | n/a | yes |
5454
| github\_app\_webhook\_secret | n/a | `string` | n/a | yes |
55+
| lambda\_s3\_bucket | S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly. | `any` | `null` | no |
5556
| lambda\_timeout | Time out of the lambda in seconds. | `number` | `10` | no |
5657
| lambda\_zip | File location of the lambda zip file. | `string` | `null` | no |
5758
| logging\_retention\_in\_days | Specifies the number of days you want to retain log events for the lambda log group. Possible values are: 0, 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653. | `number` | `7` | no |
5859
| role\_path | The path that will be added to the role, if not set the environment name will be used. | `string` | `null` | no |
5960
| role\_permissions\_boundary | Permissions boundary that will be added to the created role for the lambda. | `string` | `null` | no |
6061
| sqs\_build\_queue | SQS queue to publish accepted build events. | <pre>object({<br> id = string<br> arn = string<br> })</pre> | n/a | yes |
6162
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
63+
| webhook\_lambda\_s3\_key | S3 key for webhook lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no |
64+
| webhook\_lambda\_s3\_object\_version | S3 object version for webhook lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no |
6265

6366
## Outputs
6467

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,9 @@ variable "create_service_linked_role_spot" {
256256
type = bool
257257
default = false
258258
}
259+
260+
variable "github_server_url" {
261+
description = "(Optional) provide an alternative GitHub server url for GitHub on premise."
262+
type = string
263+
default = "https://github.com/"
264+
}

0 commit comments

Comments
 (0)