Skip to content

github/github-app-js-sample

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample GitHub App

Example of an integration via GitHub App using octokit.js.

Requirements

  • Node.js 12 or higher
  • A GitHub App subscribed to Pull Request events and with the following permissions:
    • Pull requests: Read & write
    • Metadata: Read-only
  • (For local development) A tunnel to expose your local server to the internet (e.g. smee, ngrok or cloudflared)
  • Your GitHub App Webhook must be configured to receive events at a URL that is accessible from the internet.

Setup

  1. Clone this repository.
  2. Create a .env file similar to .env.example and set actual values.
  3. Install dependencies with npm install.
  4. Start the server with npm run server.
  5. Ensure your server is reachable from the internet.
    • If you're using smee, run smee -u <smee_url> -t http://localhost:3000/api/webhook.
  6. Ensure your GitHub App includes at least one repository on its installations.

Usage

With your server running, you can now create a pull request on any repository that your app can access. GitHub will emit a pull_request.opened event and will deliver the corresponding Webhook payload to your server.

The server in this example listens for pull_request.opened events and acts on them by creating a comment on the pull request, with the message in message.md, using the octokit.js rest methods.

Security considerations

To keep things simple, this example reads the GITHUB_APP_PRIVATE_KEY from the environment. A more secure and recommended approach is to use a secrets management system like Vault, or one offered by major cloud providers: Azure Key Vault, AWS Secrets Manager, Google Secret Manager, etc.

About

Sample of a GitHub App that comments new pull requests

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy