Skip to content

Commit

Permalink
Add: webhook examples for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nayuta committed Mar 9, 2024
1 parent 2e147c1 commit 8a107c0
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/organization_webhook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Organization Webhook Example

This displays retrieval of a GitHub organization webhook.

This example will look up a GitHub organization webhook. See https://www.terraform.io/docs/providers/github/index.html for details on configuring [`providers.tf`](./providers.tf) accordingly.

Alternatively, you may use variables passed via command line:

```console
export GITHUB_ORG=
export GITHUB_TOKEN=
```

```console
terraform apply \
-var "organization=${GITHUB_ORG}" \
-var "github_token=${GITHUB_TOKEN}"
```
13 changes: 13 additions & 0 deletions examples/organization_webhook/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "github_organization_webhook" "example_com" {
configuration {
url = "https://example.com/"
content_type = "form"
insecure_ssl = false
}

active = false

events = ["issues"]
}

data "github_organization_webhooks" "all" {}
4 changes: 4 additions & 0 deletions examples/organization_webhook/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "resource_github_organization_webhooks" {
description = "The content type of the webhook"
value = data.github_organization_webhooks.all
}
12 changes: 12 additions & 0 deletions examples/organization_webhook/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
provider "github" {
owner = var.organization
token = var.github_token
}

terraform {
required_providers {
github = {
source = "integrations/github"
}
}
}
9 changes: 9 additions & 0 deletions examples/organization_webhook/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "organization" {
description = "GitHub organization used to configure the provider"
type = string
}

variable "github_token" {
description = "GitHub access token used to configure the provider"
type = string
}
19 changes: 19 additions & 0 deletions examples/repository_webhook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Repository Webhook Example

This displays retrieval of a GitHub repository webhook.

This example will look up a GitHub repository webhook. See https://www.terraform.io/docs/providers/github/index.html for details on configuring [`providers.tf`](./providers.tf) accordingly.

Alternatively, you may use variables passed via command line:

```console
export GITHUB_ORG=
export GITHUB_TOKEN=
export GITHUB_REPOSITORY=
```

```console
terraform apply \
-var "repository=${GITHUB_ORG}" \
-var "github_token=${GITHUB_TOKEN}"
```
22 changes: 22 additions & 0 deletions examples/repository_webhook/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
data "github_repository" "repo" {
full_name = var.repository
}

resource "github_repository_webhook" "example_com" {
repository = data.github_repository.repo.name

configuration {
url = "https://google.de/"
content_type = "form"
insecure_ssl = false
}

active = false

events = ["issues"]

}

data "github_repository_webhooks" "all" {
repository = data.github_repository.repo.name
}
4 changes: 4 additions & 0 deletions examples/repository_webhook/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "resource_github_repository_webhooks" {
description = "The content type of the webhooks"
value = data.github_repository_webhooks.all
}
12 changes: 12 additions & 0 deletions examples/repository_webhook/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
provider "github" {
owner = var.organization
token = var.github_token
}

terraform {
required_providers {
github = {
source = "integrations/github"
}
}
}
14 changes: 14 additions & 0 deletions examples/repository_webhook/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
variable "organization" {
description = "GitHub organization used to configure the provider"
type = string
}

variable "github_token" {
description = "GitHub access token used to configure the provider"
type = string
}

variable "repository" {
description = "GitHub repository used to configure the provider"
type = string
}

0 comments on commit 8a107c0

Please sign in to comment.