Skip to main content

Create, update and delete github webhooks with your app deployment

Project description

cloudcomponents Logo

@cloudcomponents/cdk-github-webhook

Build Status cdkdx typescript python Mentioned in Awesome CDK

Create, update and delete github webhooks with your app deployment

Install

TypeScript/JavaScript:

npm i @cloudcomponents/cdk-github-webhook

Python:

pip install cloudcomponents.cdk-github-webhook

How to use

import { GithubWebhook } from '@cloudcomponents/cdk-github-webhook';
import { SecretKey } from '@cloudcomponents/cdk-secret-key';
import { Stack, StackProps, aws_apigateway } from 'aws-cdk-lib';
import { Construct } from 'constructs';

export class GithubWebhookStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    const api = new aws_apigateway.RestApi(this, 'github-webhook');
    api.root.addMethod('POST');

    if (typeof process.env.API_TOKEN === 'undefined') {
      throw new Error('environment variable API_TOKEN undefined');
    }
    const githubApiToken = SecretKey.fromPlainText(process.env.API_TOKEN);

    // @example https://github.com/cloudcomponents/cdk-constructs
    if (typeof process.env.REPO_URL === 'undefined') {
      throw new Error('environment variable REPO_URL undefined');
    }
    const githubRepoUrl = process.env.REPO_URL;

    // @see https://developer.github.com/v3/activity/events/types/
    const events = ['*'];

    new GithubWebhook(this, 'GithubWebhook', {
      githubApiToken,
      githubRepoUrl,
      payloadUrl: api.url,
      events,
      logLevel: 'debug',
    });
  }
}

API Reference

See API.md.

Example

See more complete examples.

License

MIT

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloudcomponents.cdk-github-webhook-2.2.0.tar.gz (626.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file cloudcomponents.cdk-github-webhook-2.2.0.tar.gz.

File metadata

File hashes

Hashes for cloudcomponents.cdk-github-webhook-2.2.0.tar.gz
Algorithm Hash digest
SHA256 83a5fff3e81cd39506083b46d15cd0489c64075d8e3ac007216617e2b1b40165
MD5 9016496e1376c5e84fdfe6cd6f524bdd
BLAKE2b-256 6a593c0fad68e62a7a3677f90f1fbc5f658f18e4744e719c14a6a8b5779e76d0

See more details on using hashes here.

File details

Details for the file cloudcomponents.cdk_github_webhook-2.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cloudcomponents.cdk_github_webhook-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ea8d5a2c40975c42c6128003108999b30093ba0c3ba5248b55c72a9f973b341
MD5 39dadba573d7e556186746a2f50529ec
BLAKE2b-256 a39fd1f00c65ccb9e093b7dfd653a33a16ca752853556997a72ea5a9a4e347f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page