Skip to content

Commit 525f400

Browse files
npalmgithub-actions[bot]Navdeep Gupta
authored
feat: add module to update GitHub app webhook (#3451)
## Description Setting up the runners are requiring typically three steps 1. Create the GitHub App 2. Run terraform with App details 3. Update the GitHub App webhook. This PR adds a module that let you update the App webhook endpoint and secret via a terraform module. Usages is sown in the examples. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Navdeep Gupta <[email protected]>
1 parent 99ff767 commit 525f400

File tree

20 files changed

+313
-34
lines changed

20 files changed

+313
-34
lines changed

examples/arm64/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Be aware some shells will print some end of line character `%`.
5252
|------|--------|---------|
5353
| <a name="module_base"></a> [base](#module\_base) | ../base | n/a |
5454
| <a name="module_runners"></a> [runners](#module\_runners) | ../../ | n/a |
55+
| <a name="module_webhook-github-app"></a> [webhook-github-app](#module\_webhook-github-app) | ../../modules/webhook-github-app | n/a |
5556

5657
## Resources
5758

examples/arm64/main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,14 @@ module "runners" {
8686
# override scaling down
8787
scale_down_schedule_expression = "cron(* * * * ? *)"
8888
}
89+
90+
module "webhook-github-app" {
91+
source = "../../modules/webhook-github-app"
92+
93+
github_app = {
94+
key_base64 = var.github_app.key_base64
95+
id = var.github_app.id
96+
webhook_secret = random_id.random.hex
97+
}
98+
webhook_endpoint = module.runners.webhook.endpoint
99+
}

examples/default/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ terraform init
2222
terraform apply
2323
```
2424

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

2727
```bash
28-
terraform output -raw webhook_secret
28+
terraform output webhook_secret
2929
```
3030

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

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

5655
## Resources
5756

examples/default/main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,14 @@ module "runners" {
9797
# Enable debug logging for the lambda functions
9898
# log_level = "debug"
9999
}
100+
101+
module "webhook-github-app" {
102+
source = "../../modules/webhook-github-app"
103+
104+
github_app = {
105+
key_base64 = var.github_app.key_base64
106+
id = var.github_app.id
107+
webhook_secret = random_id.random.hex
108+
}
109+
webhook_endpoint = module.runners.webhook.endpoint
110+
}

examples/ephemeral/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ terraform init
2121
terraform apply
2222
```
2323

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

2626
```bash
27-
terraform output -raw webhook_secret
27+
terraform output webhook_secret
2828
```
2929

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

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

5454
## Resources
5555

examples/ephemeral/main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,14 @@ module "runners" {
8585
# deadLetterTargetArn = null
8686
# }
8787
}
88+
89+
module "webhook-github-app" {
90+
source = "../../modules/webhook-github-app"
91+
92+
github_app = {
93+
key_base64 = var.github_app.key_base64
94+
id = var.github_app.id
95+
webhook_secret = random_id.random.hex
96+
}
97+
webhook_endpoint = module.runners.webhook.endpoint
98+
}

examples/multi-runner/.terraform.lock.hcl

Lines changed: 35 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/multi-runner/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,12 @@ terraform init
3939
terraform apply
4040
```
4141

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

4444
```bash
45-
terraform output -raw webhook_secret
45+
terraform output webhook_secret
4646
```
4747

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

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

7372
## Resources
7473

examples/multi-runner/main.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ locals {
99
resource "random_id" "random" {
1010
byte_length = 20
1111
}
12+
1213
module "base" {
1314
source = "../base"
1415

@@ -46,3 +47,14 @@ module "multi-runner" {
4647
# Enable debug logging for the lambda functions
4748
# log_level = "debug"
4849
}
50+
51+
module "webhook-github-app" {
52+
source = "../../modules/webhook-github-app"
53+
54+
github_app = {
55+
key_base64 = var.github_app.key_base64
56+
id = var.github_app.id
57+
webhook_secret = random_id.random.hex
58+
}
59+
webhook_endpoint = module.multi-runner.webhook.endpoint
60+
}

examples/prebuilt/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,12 @@ terraform init
8686
terraform apply
8787
```
8888

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

9191
```bash
92-
terraform output -raw webhook_secret
92+
terraform output webhook_secret
9393
```
9494

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

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

121120
## Resources
122121

0 commit comments

Comments
 (0)