-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add gh-org-webhook tfm #978
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| formatter: "markdown" # this is required | ||
|
|
||
| version: "" | ||
|
|
||
| header-from: docs/header.md | ||
| footer-from: docs/footer.md | ||
|
|
||
| recursive: | ||
| enabled: false | ||
| path: modules | ||
| include-main: true | ||
|
|
||
| sections: | ||
| hide: [] | ||
| show: [] | ||
|
|
||
| content: "" | ||
|
|
||
| output: | ||
| file: "README.md" | ||
| mode: inject | ||
| template: |- | ||
| <!-- BEGIN_TF_DOCS --> | ||
| {{ .Content }} | ||
| <!-- END_TF_DOCS --> | ||
|
|
||
| output-values: | ||
| enabled: false | ||
| from: "" | ||
|
|
||
| sort: | ||
| enabled: true | ||
| by: name | ||
|
|
||
| settings: | ||
| anchor: true | ||
| color: true | ||
| default: true | ||
| description: false | ||
| escape: true | ||
| hide-empty: false | ||
| html: true | ||
| indent: 2 | ||
| lockfile: true | ||
| read-comments: true | ||
| required: true | ||
| sensitive: true | ||
| type: true |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,143 @@ | ||||||||||||||||||||||||||||||
| <!-- BEGIN_TF_DOCS --> | ||||||||||||||||||||||||||||||
| # **GitHub Organization Webhook Terraform Module** | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ## Overview | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| This module creates and manages a GitHub **organization-level webhook** using a single strongly-typed `config` object. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| It is designed for Prefapp’s Internal Developer Platform and automated webhook provisioning pipelines. The module accepts input directly from external programs via JSON. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ## Key Features | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - **Single config object**: All webhook settings in one `config` variable | ||||||||||||||||||||||||||||||
| - **Full event support**: Subscribe to any GitHub organization webhook event | ||||||||||||||||||||||||||||||
| - **Secure by default**: Supports secret, content type, and SSL validation | ||||||||||||||||||||||||||||||
| - **JSON-native**: Perfect for programmatic generation | ||||||||||||||||||||||||||||||
| - **Strong validation**: Ensures only valid events and required fields | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ## Supported Events | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| The module supports **all standard GitHub organization webhook events**. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Common events include: | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - `push` | ||||||||||||||||||||||||||||||
| - `pull_request` | ||||||||||||||||||||||||||||||
| - `issues` | ||||||||||||||||||||||||||||||
| - `workflow_run` | ||||||||||||||||||||||||||||||
| - `workflow_dispatch` | ||||||||||||||||||||||||||||||
| - `release` | ||||||||||||||||||||||||||||||
| - `create` | ||||||||||||||||||||||||||||||
| - `delete` | ||||||||||||||||||||||||||||||
| - `fork` | ||||||||||||||||||||||||||||||
| - `member` | ||||||||||||||||||||||||||||||
| - `public` | ||||||||||||||||||||||||||||||
| - `repository` | ||||||||||||||||||||||||||||||
| - `status` | ||||||||||||||||||||||||||||||
| - `watch` | ||||||||||||||||||||||||||||||
| - `commit_comment` | ||||||||||||||||||||||||||||||
| - `gollum` | ||||||||||||||||||||||||||||||
| - `team_add` | ||||||||||||||||||||||||||||||
| - `team` | ||||||||||||||||||||||||||||||
| - `organization` | ||||||||||||||||||||||||||||||
| - `project` | ||||||||||||||||||||||||||||||
| - `project_card` | ||||||||||||||||||||||||||||||
| - `project_column` | ||||||||||||||||||||||||||||||
| - `milestone` | ||||||||||||||||||||||||||||||
| - `deployment` | ||||||||||||||||||||||||||||||
| - `deployment_status` | ||||||||||||||||||||||||||||||
| - `discussion` | ||||||||||||||||||||||||||||||
| - `discussion_comment` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| For the **complete and up-to-date list** of all available webhook events and their payloads, see the official GitHub documentation: | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| → **[Webhook events and payloads](https://docs.github.com/en/webhooks/webhook-events-and-payloads)** | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ## Basic Usage | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ### Using `terraform.tfvars.json` (recommended) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ```hcl | ||||||||||||||||||||||||||||||
| module "org_webhook" { | ||||||||||||||||||||||||||||||
| source = "git::https://github.com/prefapp/tfm.git//modules/gh-org-webhook" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| config = var.config | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ### Inline example | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ```hcl | ||||||||||||||||||||||||||||||
| module "org\_webhook" { | ||||||||||||||||||||||||||||||
| source = "git::https://github.com/prefapp/tfm.git//modules/gh-org-webhook" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| config = { | ||||||||||||||||||||||||||||||
|
Comment on lines
+69
to
+73
|
||||||||||||||||||||||||||||||
| webhook = { | ||||||||||||||||||||||||||||||
| active = true | ||||||||||||||||||||||||||||||
| events = ["push", "pull\_request", "issues", "workflow\_run"] | ||||||||||||||||||||||||||||||
|
Comment on lines
+70
to
+76
|
||||||||||||||||||||||||||||||
| module "org\_webhook" { | |
| source = "git::https://github.com/prefapp/tfm.git//modules/gh-org-webhook" | |
| config = { | |
| webhook = { | |
| active = true | |
| events = ["push", "pull\_request", "issues", "workflow\_run"] | |
| module "org_webhook" { | |
| source = "git::https://github.com/prefapp/tfm.git//modules/gh-org-webhook" | |
| config = { | |
| webhook = { | |
| active = true | |
| events = ["push", "pull_request", "issues", "workflow_run"] |
Copilot
AI
Mar 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There’s an extra stray triple-backtick line after the inline example closes, which breaks markdown formatting. Remove the extra ``` so fences are balanced.
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "config": { | ||
| "webhook": { | ||
| "active": true, | ||
| "events": [ | ||
| "push", | ||
| "pull_request", | ||
| "issues" | ||
| ], | ||
| "configuration": { | ||
| "url": "https://example.com/webhook", | ||
| "contentType": "json", | ||
| "secret": "secret-xxx", | ||
| "insecureSsl": false | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| terraform { | ||
| required_providers { | ||
| github = { | ||
| source = "integrations/github" | ||
| version = "~> 6.0" | ||
|
Comment on lines
+1
to
+5
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| module "org_webhook" { | ||
| source = "../../" | ||
|
|
||
| config = jsondecode(file("${path.module}/config.json")).config | ||
| } | ||
|
|
||
| output "webhook_id" { | ||
| value = module.org_webhook.webhook_id | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,16 @@ | ||||||
| ### `docs/footer.md` | ||||||
| ```markdown | ||||||
|
Comment on lines
+1
to
+2
|
||||||
| ### `docs/footer.md` | |
| ```markdown |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,85 @@ | ||||||||||||||||||||||||||||||||||
| # **GitHub Organization Webhook Terraform Module** | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ## Overview | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| This module creates and manages a GitHub **organization-level webhook** using a single strongly-typed `config` object. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| It is designed for Prefapp’s Internal Developer Platform and automated webhook provisioning pipelines. The module accepts input directly from external programs via JSON. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ## Key Features | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - **Single config object**: All webhook settings in one `config` variable | ||||||||||||||||||||||||||||||||||
| - **Full event support**: Subscribe to any GitHub organization webhook event | ||||||||||||||||||||||||||||||||||
| - **Secure by default**: Supports secret, content type, and SSL validation | ||||||||||||||||||||||||||||||||||
| - **JSON-native**: Perfect for programmatic generation | ||||||||||||||||||||||||||||||||||
| - **Strong validation**: Ensures only valid events and required fields | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| ## Supported Events | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| The module supports **all standard GitHub organization webhook events**. | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+12
to
+19
|
||||||||||||||||||||||||||||||||||
| - **Full event support**: Subscribe to any GitHub organization webhook event | |
| - **Secure by default**: Supports secret, content type, and SSL validation | |
| - **JSON-native**: Perfect for programmatic generation | |
| - **Strong validation**: Ensures only valid events and required fields | |
| ## Supported Events | |
| The module supports **all standard GitHub organization webhook events**. | |
| - **Comprehensive event coverage**: Subscribe to a wide range of common GitHub organization webhook events | |
| - **Secure by default**: Supports secret, content type, and SSL validation | |
| - **JSON-native**: Perfect for programmatic generation | |
| - **Strong validation**: Ensures only valid events and required fields | |
| ## Supported Events | |
| This module currently supports the following GitHub organization webhook events: |
Copilot
AI
Mar 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This markdown opens a hcl code fence for the first example but never closes it before the next heading, which breaks rendering. Add the missing closing after the first module example.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| resource "github_organization_webhook" "this" { | ||
| active = var.config.webhook.active | ||
| events = var.config.webhook.events | ||
|
|
||
| configuration { | ||
| url = var.config.webhook.configuration.url | ||
| content_type = var.config.webhook.configuration.contentType | ||
| secret = var.config.webhook.configuration.secret | ||
| insecure_ssl = var.config.webhook.configuration.insecureSsl | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| output "webhook_id" { | ||
| description = "ID of the created organization webhook" | ||
| value = github_organization_webhook.this.id | ||
| } | ||
|
|
||
| output "webhook_url" { | ||
| description = "URL of the webhook" | ||
| value = github_organization_webhook.this.configuration[0].url | ||
| } | ||
|
|
||
| output "active" { | ||
| description = "Whether the webhook is active" | ||
| value = github_organization_webhook.this.active | ||
| } | ||
|
|
||
| output "events" { | ||
| description = "Events the webhook is subscribed to" | ||
| value = github_organization_webhook.this.events | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,28 @@ | ||||||||||||||
| variable "config" { | ||||||||||||||
| description = "GitHub organization webhook configuration" | ||||||||||||||
| type = object({ | ||||||||||||||
| webhook = object({ | ||||||||||||||
| active = optional(bool, true) | ||||||||||||||
| events = list(string) | ||||||||||||||
|
|
||||||||||||||
| configuration = object({ | ||||||||||||||
| url = string | ||||||||||||||
| contentType = optional(string, "json") | ||||||||||||||
| secret = optional(string) | ||||||||||||||
| insecureSsl = optional(bool, false) | ||||||||||||||
| }) | ||||||||||||||
| }) | ||||||||||||||
| }) | ||||||||||||||
|
|
||||||||||||||
| validation { | ||||||||||||||
| condition = length(var.config.webhook.events) > 0 | ||||||||||||||
| error_message = "At least one event must be defined in webhook.events." | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| validation { | ||||||||||||||
| condition = alltrue([ | ||||||||||||||
| for e in var.config.webhook.events : contains(["push", "pull_request", "issues", "commit_comment", "create", "delete", "fork", "gollum", "member", "public", "release", "status", "watch", "workflow_dispatch"], e) | ||||||||||||||
| ]) | ||||||||||||||
| error_message = "Invalid event type in webhook.events." | ||||||||||||||
|
Comment on lines
+24
to
+26
|
||||||||||||||
| for e in var.config.webhook.events : contains(["push", "pull_request", "issues", "commit_comment", "create", "delete", "fork", "gollum", "member", "public", "release", "status", "watch", "workflow_dispatch"], e) | |
| ]) | |
| error_message = "Invalid event type in webhook.events." | |
| for e in var.config.webhook.events : length(trim(e)) > 0 | |
| ]) | |
| error_message = "Each webhook event must be a non-empty string." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README’s first usage example opens a ```hcl fence but doesn’t close it after the module block, so the subsequent heading gets rendered as code. Close the code fence after the first example (and re-run terraform-docs if this file is generated).