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

feat: add module to update GitHub app webhook #3451

Merged
merged 6 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/arm64/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Be aware some shells will print some end of line character `%`.
|------|--------|---------|
| <a name="module_base"></a> [base](#module\_base) | ../base | n/a |
| <a name="module_runners"></a> [runners](#module\_runners) | ../../ | n/a |
| <a name="module_webhook-github-app"></a> [webhook-github-app](#module\_webhook-github-app) | ../../modules/webhook-github-app | n/a |

## Resources

Expand Down
11 changes: 11 additions & 0 deletions examples/arm64/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,14 @@ module "runners" {
# override scaling down
scale_down_schedule_expression = "cron(* * * * ? *)"
}

module "webhook-github-app" {
source = "../../modules/webhook-github-app"

github_app = {
key_base64 = var.github_app.key_base64
id = var.github_app.id
webhook_secret = random_id.random.hex
}
webhook_endpoint = module.runners.webhook.endpoint
}
7 changes: 3 additions & 4 deletions examples/default/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ terraform init
terraform apply
```

You can receive the webhook details by running:
The module will try to update the GitHub App webhook and secret (only linux/mac). You can receive the webhook details by running:

```bash
terraform output -raw webhook_secret
terraform output webhook_secret
```

Be aware some shells will print some end of line character `%`.

<!-- BEGIN_TF_DOCS -->
## Requirements

Expand All @@ -52,6 +50,7 @@ Be aware some shells will print some end of line character `%`.
|------|--------|---------|
| <a name="module_base"></a> [base](#module\_base) | ../base | n/a |
| <a name="module_runners"></a> [runners](#module\_runners) | ../../ | n/a |
| <a name="module_webhook-github-app"></a> [webhook-github-app](#module\_webhook-github-app) | ../../modules/webhook-github-app | n/a |

## Resources

Expand Down
11 changes: 11 additions & 0 deletions examples/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,14 @@ module "runners" {
# Enable debug logging for the lambda functions
# log_level = "debug"
}

module "webhook-github-app" {
source = "../../modules/webhook-github-app"

github_app = {
key_base64 = var.github_app.key_base64
id = var.github_app.id
webhook_secret = random_id.random.hex
}
webhook_endpoint = module.runners.webhook.endpoint
}
6 changes: 3 additions & 3 deletions examples/ephemeral/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ terraform init
terraform apply
```

You can receive the webhook details by running:
The module will try to update the GitHub App webhook and secret (only linux/mac). You can receive the webhook details by running:

```bash
terraform output -raw webhook_secret
terraform output webhook_secret
```

Be aware some shells will print some end of line character `%`.
<!-- BEGIN_TF_DOCS -->
## Requirements

Expand All @@ -50,6 +49,7 @@ Be aware some shells will print some end of line character `%`.
|------|--------|---------|
| <a name="module_base"></a> [base](#module\_base) | ../base | n/a |
| <a name="module_runners"></a> [runners](#module\_runners) | ../../ | n/a |
| <a name="module_webhook-github-app"></a> [webhook-github-app](#module\_webhook-github-app) | ../../modules/webhook-github-app | n/a |

## Resources

Expand Down
11 changes: 11 additions & 0 deletions examples/ephemeral/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,14 @@ module "runners" {
# deadLetterTargetArn = null
# }
}

module "webhook-github-app" {
source = "../../modules/webhook-github-app"

github_app = {
key_base64 = var.github_app.key_base64
id = var.github_app.id
webhook_secret = random_id.random.hex
}
webhook_endpoint = module.runners.webhook.endpoint
}
52 changes: 35 additions & 17 deletions examples/multi-runner/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions examples/multi-runner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ terraform init
terraform apply
```

You can receive the webhook details by running:
The module will try to update the GitHub App webhook and secret (only linux/mac). You can receive the webhook details by running:

```bash
terraform output -raw webhook_secret
terraform output webhook_secret
```

Be aware some shells will print some end of line character `%`.

<!-- BEGIN_TF_DOCS -->
## Requirements

Expand All @@ -69,6 +67,7 @@ Be aware some shells will print some end of line character `%`.
|------|--------|---------|
| <a name="module_base"></a> [base](#module\_base) | ../base | n/a |
| <a name="module_multi-runner"></a> [multi-runner](#module\_multi-runner) | ../../modules/multi-runner | n/a |
| <a name="module_webhook-github-app"></a> [webhook-github-app](#module\_webhook-github-app) | ../../modules/webhook-github-app | n/a |

## Resources

Expand Down
12 changes: 12 additions & 0 deletions examples/multi-runner/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ locals {
resource "random_id" "random" {
byte_length = 20
}

module "base" {
source = "../base"

Expand Down Expand Up @@ -46,3 +47,14 @@ module "multi-runner" {
# Enable debug logging for the lambda functions
# log_level = "debug"
}

module "webhook-github-app" {
source = "../../modules/webhook-github-app"

github_app = {
key_base64 = var.github_app.key_base64
id = var.github_app.id
webhook_secret = random_id.random.hex
}
webhook_endpoint = module.multi-runner.webhook.endpoint
}
7 changes: 3 additions & 4 deletions examples/prebuilt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,12 @@ terraform init
terraform apply
```

You can receive the webhook details by running:
The module will try to update the GitHub App webhook and secret (only linux/mac). You can receive the webhook details by running:

```bash
terraform output -raw webhook_secret
terraform output webhook_secret
```

Be aware some shells will print some end of line character `%`.

<!-- BEGIN_TF_DOCS -->
## Requirements

Expand All @@ -117,6 +115,7 @@ Be aware some shells will print some end of line character `%`.
|------|--------|---------|
| <a name="module_base"></a> [base](#module\_base) | ../base | n/a |
| <a name="module_runners"></a> [runners](#module\_runners) | ../../ | n/a |
| <a name="module_webhook-github-app"></a> [webhook-github-app](#module\_webhook-github-app) | ../../modules/webhook-github-app | n/a |

## Resources

Expand Down
11 changes: 11 additions & 0 deletions examples/prebuilt/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,14 @@ module "runners" {
# override scaling down
scale_down_schedule_expression = "cron(* * * * ? *)"
}

module "webhook-github-app" {
source = "../../modules/webhook-github-app"

github_app = {
key_base64 = var.github_app.key_base64
id = var.github_app.id
webhook_secret = random_id.random.hex
}
webhook_endpoint = module.runners.webhook.endpoint
}
9 changes: 8 additions & 1 deletion examples/ubuntu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ terraform init
terraform apply
```

The module will try to update the GitHub App webhook and secret (only linux/mac). You can receive the webhook details by running:

```bash
terraform output webhook_secret
```

<!-- BEGIN_TF_DOCS -->
## Requirements

Expand All @@ -45,6 +51,7 @@ terraform apply
|------|--------|---------|
| <a name="module_base"></a> [base](#module\_base) | ../base | n/a |
| <a name="module_runners"></a> [runners](#module\_runners) | ../../ | n/a |
| <a name="module_webhook-github-app"></a> [webhook-github-app](#module\_webhook-github-app) | ../../modules/webhook-github-app | n/a |

## Resources

Expand All @@ -65,4 +72,4 @@ terraform apply
| <a name="output_runners"></a> [runners](#output\_runners) | n/a |
| <a name="output_webhook_endpoint"></a> [webhook\_endpoint](#output\_webhook\_endpoint) | n/a |
| <a name="output_webhook_secret"></a> [webhook\_secret](#output\_webhook\_secret) | n/a |
<!-- END_TF_DOCS -->
<!-- END_TF_DOCS -->
11 changes: 11 additions & 0 deletions examples/ubuntu/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,14 @@ module "runners" {
# Enable logging all commands of user_data, secrets will be logged!!!
# enable_user_data_debug_logging_runner = true
}

module "webhook-github-app" {
source = "../../modules/webhook-github-app"

github_app = {
key_base64 = var.github_app.key_base64
id = var.github_app.id
webhook_secret = random_id.random.hex
}
webhook_endpoint = module.runners.webhook.endpoint
}
9 changes: 8 additions & 1 deletion examples/windows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ terraform apply

_**Note**_: It can take upwards of ten minutes for a runner to start processing jobs, and about as long for logs to start showing up. It's recommend that scale the runners via a warm-up job and then keep them idled.

The module will try to update the GitHub App webhook and secret (only linux/mac). You can receive the webhook details by running:

```bash
terraform output webhook_secret
```

<!-- BEGIN_TF_DOCS -->
## Requirements

Expand All @@ -47,6 +53,7 @@ _**Note**_: It can take upwards of ten minutes for a runner to start processing
|------|--------|---------|
| <a name="module_base"></a> [base](#module\_base) | ../base | n/a |
| <a name="module_runners"></a> [runners](#module\_runners) | ../../ | n/a |
| <a name="module_webhook-github-app"></a> [webhook-github-app](#module\_webhook-github-app) | ../../modules/webhook-github-app | n/a |

## Resources

Expand All @@ -67,4 +74,4 @@ _**Note**_: It can take upwards of ten minutes for a runner to start processing
| <a name="output_runners"></a> [runners](#output\_runners) | n/a |
| <a name="output_webhook_endpoint"></a> [webhook\_endpoint](#output\_webhook\_endpoint) | n/a |
| <a name="output_webhook_secret"></a> [webhook\_secret](#output\_webhook\_secret) | n/a |
<!-- END_TF_DOCS -->
<!-- END_TF_DOCS -->
11 changes: 11 additions & 0 deletions examples/windows/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,14 @@ module "runners" {
# override scaling down for testing
scale_down_schedule_expression = "cron(* * * * ? *)"
}

module "webhook-github-app" {
source = "../../modules/webhook-github-app"

github_app = {
key_base64 = var.github_app.key_base64
id = var.github_app.id
webhook_secret = random_id.random.hex
}
webhook_endpoint = module.runners.webhook.endpoint
}
41 changes: 41 additions & 0 deletions modules/webhook-github-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Module - Update GitHub App Webhook

> This module is using the local executor to run a bash script.

This module updates the GitHub App webhook with the endpoint and secret and can be chainged with the root module. See the examples for usages.
npalm marked this conversation as resolved.
Show resolved Hide resolved

<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | ~> 3 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_null"></a> [null](#provider\_null) | ~> 3 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [null_resource.update_app](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_github_app"></a> [github\_app](#input\_github\_app) | GitHub app parameters, see your github app. Ensure the key is the base64-encoded `.pem` file (the output of `base64 app.private-key.pem`, not the content of `private-key.pem`). | <pre>object({<br> key_base64 = string<br> id = string<br> webhook_secret = string<br> })</pre> | n/a | yes |
| <a name="input_webhook_endpoint"></a> [webhook\_endpoint](#input\_webhook\_endpoint) | The endpoint to use for the webhook, defaults to the endpoint of the runners module. | `string` | n/a | yes |

## Outputs

No outputs.
<!-- END_TF_DOCS -->
Loading