https://github.com/github-developer/using-the-github-api-in-your-app
https://github.com/github-developer/using-the-github-api-in-your-app
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/github-developer/using-the-github-api-in-your-app
- Owner: github-developer
- Archived: true
- Created: 2018-08-15T19:40:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-06-08T15:55:57.000Z (almost 3 years ago)
- Last Synced: 2024-07-18T20:41:33.371Z (over 1 year ago)
- Language: Ruby
- Size: 22.5 KB
- Stars: 129
- Watchers: 32
- Forks: 136
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
⚠️ Note: This repository is not maintained. For more recent guides about how to build GitHub Apps, see "[About writing code for a GitHub App](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/about-writing-code-for-a-github-app)."
This is an example GitHub App that adds a label to all new issues opened in a repository. You can follow the archived "[Using the GitHub API in your app](https://web.archive.org/web/20230604175646/https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/using-the-github-api-in-your-app)" guide to learn how to build the app code in `server.rb`.
This project listens for webhook events and uses the Octokit.rb library to make REST API calls. This example project consists of two different servers:
* `template_server.rb` (GitHub App template code)
* `server.rb` (completed project)
To learn how to set up a template GitHub App, follow the archived "[Setting up your development environment](https://web.archive.org/web/20230604175646/https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/setting-up-your-development-environment-to-create-a-github-app)" guide.
## Install
To run the code, make sure you have [Bundler](https://bundler.io/) installed; then enter `bundle install` on the command line.
## Set environment variables
1. Create a copy of the `.env-example` file called `.env`.
2. Add your GitHub App's private key, app ID, and webhook secret to the `.env` file.
## Run the server
1. Run `ruby template_server.rb` or `ruby server.rb` on the command line.
1. View the default Sinatra app at `localhost:3000`.