Skip to content

Commit a0f1f46

Browse files
authored
Initial implementation (#1)
* Implement GitHub repository webhooks * Update readme * Bump ci * Fix formatting * Address PR
1 parent 21417e6 commit a0f1f46

File tree

11 files changed

+460
-1
lines changed

11 files changed

+460
-1
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Compiled files
2+
*.tfstate
3+
*.tfstate.backup
4+
5+
# Module directory
6+
.terraform/
7+
.idea
8+
*.iml
9+
10+
.build-harness
11+
build-harness

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
addons:
2+
apt:
3+
packages:
4+
- git
5+
- make
6+
- curl
7+
8+
install:
9+
- make init
10+
11+
script:
12+
- make terraform/install
13+
- make terraform/get-plugins
14+
- make terraform/get-modules
15+
- make terraform/lint
16+
- make terraform/validate

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SHELL := /bin/bash
2+
3+
# List of targets the `readme` target should call before generating the readme
4+
export README_DEPS ?= docs/targets.md docs/terraform.md
5+
6+
-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness)
7+
8+
## Lint terraform code
9+
lint:
10+
$(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate

README.md

Lines changed: 224 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,225 @@
1+
<!-- This file was automatically generated by the `build-harness`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->
2+
3+
4+
[![Cloud Posse](https://cloudposse.com/logo-300x69.svg)](https://cloudposse.com)
5+
16
# terraform-github-repository-webhooks
2-
Terraform module to provision webhooks on a set of GitHub repositories
7+
8+
[![Build Status](https://travis-ci.org/cloudposse/terraform-github-repository-webhooks.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-github-repository-webhooks) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-github-repository-webhooks.svg)](https://github.com/cloudposse/terraform-github-repository-webhooks/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
9+
10+
11+
Terraform module to provision webhooks on a set of GitHub repositories.
12+
This is useful if you need to register a webhook en masse across dozens of repositories.
13+
14+
15+
---
16+
17+
This project is part of our comprehensive ["SweetOps"](https://docs.cloudposse.com) approach towards DevOps.
18+
19+
20+
It's 100% Open Source and licensed under the [APACHE2](LICENSE).
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
## Usage
32+
33+
Create a GitHub Personal Access Token that has `admin:repo_hook` for full control of repository hooks; in otherwords, we need `write:repo_hook` to write repository hooks and `read:repo_hook` to read repository hooks.
34+
35+
```hcl
36+
module "github_webhooks" {
37+
source = "git::https://github.com/cloudposse/terraform-github-repository-webhooks.git?ref=master"
38+
github_organization = "cloudposse"
39+
github_token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
40+
github_repositories = "geodesic"
41+
webhook_url = "https://atlantis.prod.company.com/"
42+
content_type = "application/json"
43+
events = ["issues"]
44+
}
45+
```
46+
47+
48+
49+
50+
51+
52+
## Makefile Targets
53+
```
54+
Available targets:
55+
56+
help Help screen
57+
help/all Display help for all targets
58+
help/short This help short screen
59+
lint Lint terraform code
60+
61+
```
62+
63+
## Inputs
64+
65+
| Name | Description | Type | Default | Required |
66+
|------|-------------|:----:|:-----:|:-----:|
67+
| active | Indicate of the webhook should receive events. | string | `true` | no |
68+
| enabled | Whether or not to enable this module | string | `true` | no |
69+
| events | A list of events which should trigger the webhook. | list | `<list>` | no |
70+
| github_organization | GitHub organization to use when creating webhook | string | - | yes |
71+
| github_repositories | List of repository names which should be associated with the webhook | list | `<list>` | no |
72+
| github_token | GitHub token used for API access | string | - | yes |
73+
| name | The type of webhook | string | `web` | no |
74+
| webhook_content_type | Webhook Content Type (E.g. application/json) | string | `application/json` | no |
75+
| webhook_insecure_ssl | Webhook Insecure SSL (E.g. trust self-signed certificates) | string | `false` | no |
76+
| webhook_secret | Webhook secret | string | `` | no |
77+
| webhook_url | Webhook URL | string | - | yes |
78+
79+
80+
81+
82+
## Related Projects
83+
84+
Check out these related projects.
85+
86+
- [terraform-aws-cicd](https://github.com/cloudposse/terraform-aws-cicd) - Terraform Module for CI/CD with AWS Code Pipeline and Code Build
87+
- [terraform-aws-codebuild](https://github.com/cloudposse/terraform-aws-codebuild) - Terraform Module to easily leverage AWS CodeBuild for Continuous Integration
88+
89+
90+
91+
92+
## References
93+
94+
For additional context, refer to some of these links.
95+
96+
- [GitHub Event Types](https://developer.github.com/v3/activity/events/types/) - The list of supported event types which can trigger a webhook
97+
- [GitHub Hook Types](https://api.github.com/hooks) - The type of the webhooks.
98+
99+
100+
## Help
101+
102+
**Got a question?**
103+
104+
File a GitHub [issue](https://github.com/cloudposse/terraform-github-repository-webhooks/issues), send us an [email][email] or join our [Slack Community][slack].
105+
106+
## Commercial Support
107+
108+
Work directly with our team of DevOps experts via email, slack, and video conferencing.
109+
110+
We provide [*commercial support*][commercial_support] for all of our [Open Source][github] projects. As a *Dedicated Support* customer, you have access to our team of subject matter experts at a fraction of the cost of a full-time engineer.
111+
112+
[![E-Mail](https://img.shields.io/badge/[email protected])](mailto:[email protected])
113+
114+
- **Questions.** We'll use a Shared Slack channel between your team and ours.
115+
- **Troubleshooting.** We'll help you triage why things aren't working.
116+
- **Code Reviews.** We'll review your Pull Requests and provide constructive feedback.
117+
- **Bug Fixes.** We'll rapidly work to fix any bugs in our projects.
118+
- **Build New Terraform Modules.** We'll develop original modules to provision infrastructure.
119+
- **Cloud Architecture.** We'll assist with your cloud strategy and design.
120+
- **Implementation.** We'll provide hands-on support to implement our reference architectures.
121+
122+
123+
## Community Forum
124+
125+
Get access to our [Open Source Community Forum][slack] on Slack. It's **FREE** to join for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build *sweet* infrastructure.
126+
127+
## Contributing
128+
129+
### Bug Reports & Feature Requests
130+
131+
Please use the [issue tracker](https://github.com/cloudposse/terraform-github-repository-webhooks/issues) to report any bugs or file feature requests.
132+
133+
### Developing
134+
135+
If you are interested in being a contributor and want to get involved in developing this project or [help out](https://github.com/orgs/cloudposse/projects/3) with our other projects, we would love to hear from you! Shoot us an [email](mailto:[email protected]).
136+
137+
In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
138+
139+
1. **Fork** the repo on GitHub
140+
2. **Clone** the project to your own machine
141+
3. **Commit** changes to your own branch
142+
4. **Push** your work back up to your fork
143+
5. Submit a **Pull Request** so that we can review your changes
144+
145+
**NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request!
146+
147+
148+
## Copyright
149+
150+
Copyright © 2017-2018 [Cloud Posse, LLC](https://cloudposse.com)
151+
152+
153+
154+
## License
155+
156+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
157+
158+
See [LICENSE](LICENSE) for full details.
159+
160+
Licensed to the Apache Software Foundation (ASF) under one
161+
or more contributor license agreements. See the NOTICE file
162+
distributed with this work for additional information
163+
regarding copyright ownership. The ASF licenses this file
164+
to you under the Apache License, Version 2.0 (the
165+
"License"); you may not use this file except in compliance
166+
with the License. You may obtain a copy of the License at
167+
168+
https://www.apache.org/licenses/LICENSE-2.0
169+
170+
Unless required by applicable law or agreed to in writing,
171+
software distributed under the License is distributed on an
172+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
173+
KIND, either express or implied. See the License for the
174+
specific language governing permissions and limitations
175+
under the License.
176+
177+
178+
179+
180+
181+
182+
183+
184+
185+
## Trademarks
186+
187+
All other trademarks referenced herein are the property of their respective owners.
188+
189+
## About
190+
191+
This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know at <[email protected]>
192+
193+
[![Cloud Posse](https://cloudposse.com/logo-300x69.svg)](https://cloudposse.com)
194+
195+
We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We love [Open Source Software](https://github.com/cloudposse/)!
196+
197+
We offer paid support on all of our projects.
198+
199+
Check out [our other projects][github], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation.
200+
201+
[docs]: https://docs.cloudposse.com/
202+
[website]: https://cloudposse.com/
203+
[github]: https://github.com/cloudposse/
204+
[commercial_support]: https://github.com/orgs/cloudposse/projects
205+
[jobs]: https://cloudposse.com/jobs/
206+
[hire]: https://cloudposse.com/contact/
207+
[slack]: https://slack.cloudposse.com/
208+
[linkedin]: https://www.linkedin.com/company/cloudposse
209+
[twitter]: https://twitter.com/cloudposse/
210+
[email]: mailto:[email protected]
211+
212+
213+
### Contributors
214+
215+
| [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]<br/>[Igor Rodionov][goruha_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]<br/>[Andriy Knysh][aknysh_homepage] |
216+
|---|---|---|
217+
218+
[osterman_homepage]: https://github.com/osterman
219+
[osterman_avatar]: https://github.com/osterman.png?size=150
220+
[goruha_homepage]: https://github.com/goruha
221+
[goruha_avatar]: https://github.com/goruha.png?size=150
222+
[aknysh_homepage]: https://github.com/aknysh
223+
[aknysh_avatar]: https://github.com/aknysh.png?size=150
224+
225+

README.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
#
3+
# This is the canonical configuration for the `README.md`
4+
# Run `make readme` to rebuild the `README.md`
5+
#
6+
7+
# Name of this project
8+
name: terraform-github-repository-webhooks
9+
10+
# License of this project
11+
license: "APACHE2"
12+
13+
# Canonical GitHub repo
14+
github_repo: cloudposse/terraform-github-repository-webhooks
15+
16+
# Short description of this project
17+
description: |-
18+
Terraform module to provision webhooks on a set of GitHub repositories.
19+
This is useful if you need to register a webhook en masse across dozens of repositories.
20+
21+
# Badges to display
22+
badges:
23+
- name: "Build Status"
24+
image: "https://travis-ci.org/cloudposse/terraform-github-repository-webhooks.svg?branch=master"
25+
url: "https://travis-ci.org/cloudposse/terraform-github-repository-webhooks"
26+
- name: "Latest Release"
27+
image: "https://img.shields.io/github/release/cloudposse/terraform-github-repository-webhooks.svg"
28+
url: "https://github.com/cloudposse/terraform-github-repository-webhooks/releases/latest"
29+
- name: "Slack Community"
30+
image: "https://slack.cloudposse.com/badge.svg"
31+
url: "https://slack.cloudposse.com"
32+
33+
# How to use this project
34+
usage: |-
35+
Create a GitHub Personal Access Token that has `admin:repo_hook` for full control of repository hooks; in otherwords, we need `write:repo_hook` to write repository hooks and `read:repo_hook` to read repository hooks.
36+
37+
```hcl
38+
module "github_webhooks" {
39+
source = "git::https://github.com/cloudposse/terraform-github-repository-webhooks.git?ref=master"
40+
github_organization = "cloudposse"
41+
github_token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
42+
github_repositories = "geodesic"
43+
webhook_url = "https://atlantis.prod.company.com/"
44+
content_type = "application/json"
45+
events = ["issues"]
46+
}
47+
```
48+
49+
include:
50+
- "docs/targets.md"
51+
- "docs/terraform.md"
52+
53+
related:
54+
- name: "terraform-aws-cicd"
55+
description: "Terraform Module for CI/CD with AWS Code Pipeline and Code Build"
56+
url: "https://github.com/cloudposse/terraform-aws-cicd"
57+
- name: "terraform-aws-codebuild"
58+
description: "Terraform Module to easily leverage AWS CodeBuild for Continuous Integration"
59+
url: "https://github.com/cloudposse/terraform-aws-codebuild"
60+
61+
references:
62+
- name: "GitHub Event Types"
63+
description: "The list of supported event types which can trigger a webhook"
64+
url: "https://developer.github.com/v3/activity/events/types/"
65+
- name: "GitHub Hook Types"
66+
description: "The type of the webhooks."
67+
url: "https://api.github.com/hooks"
68+
69+
# Contributors to this project
70+
contributors:
71+
- name: "Erik Osterman"
72+
github: "osterman"
73+
- name: "Igor Rodionov"
74+
github: "goruha"
75+
- name: "Andriy Knysh"
76+
github: "aknysh"

docs/targets.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Makefile Targets
2+
```
3+
Available targets:
4+
5+
help Help screen
6+
help/all Display help for all targets
7+
help/short This help short screen
8+
lint Lint terraform code
9+
10+
```

docs/terraform.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
## Inputs
3+
4+
| Name | Description | Type | Default | Required |
5+
|------|-------------|:----:|:-----:|:-----:|
6+
| active | Indicate of the webhook should receive events. | string | `true` | no |
7+
| enabled | Whether or not to enable this module | string | `true` | no |
8+
| events | A list of events which should trigger the webhook. | list | `<list>` | no |
9+
| github_organization | GitHub organization to use when creating webhook | string | - | yes |
10+
| github_repositories | List of repository names which should be associated with the webhook | list | `<list>` | no |
11+
| github_token | GitHub token used for API access | string | - | yes |
12+
| name | The type of webhook | string | `web` | no |
13+
| webhook_content_type | Webhook Content Type (E.g. application/json) | string | `application/json` | no |
14+
| webhook_insecure_ssl | Webhook Insecure SSL (E.g. trust self-signed certificates) | string | `false` | no |
15+
| webhook_secret | Webhook secret | string | `` | no |
16+
| webhook_url | Webhook URL | string | - | yes |
17+

examples/simple/main.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
variable "github_token" {
2+
description = "GitHub token used for API access"
3+
}
4+
5+
module "webhooks" {
6+
source = "../../"
7+
active = false
8+
github_token = "${var.github_token}"
9+
github_organization = "cloudposse"
10+
github_repositories = ["terraform-github-repository-webhooks"]
11+
webhook_url = "https://docs.cloudposse.com"
12+
}

0 commit comments

Comments
 (0)