|
| 1 | +# GitHub App Setup |
| 2 | + |
| 3 | +The following steps will guide you through the process of setting up a GitHub App for the project. This setup is essential for the bot to function correctly and interact with GitHub's WebHook events. |
| 4 | + |
| 5 | +## Step 1: Create a GitHub App |
| 6 | +Navigate to your organization, under settings click on "Developer settings" and then "GitHub Apps". Click on "New GitHub App". You can also navigate to the following url, replacing the organization with your own: |
| 7 | +`https://github.com/organizations/<organization>/settings/apps` |
| 8 | + |
| 9 | +### Step 1.1: Fill in the App Details |
| 10 | +- **GitHub App name**: Enter a name for your app. This will be displayed to users when they install the app. |
| 11 | +- **Homepage URL**: Enter the URL of your app's homepage. This can be a link to your project's GitHub repository or documentation. |
| 12 | +- **Webhook URL**: Enter the URL where your app will receive WebHook events. This should be the endpoint that handles incoming events from GitHub. |
| 13 | +- **Webhook secret**: Generate a secret key for your app. This will be used to verify the authenticity of incoming WebHook events. |
| 14 | +- **Permissions**: Set the permissions your app needs. For this project, you will need to set the following permissions: |
| 15 | + - **Repository permissions**: |
| 16 | + - **Administration**: Read and write access |
| 17 | + - **Contents**: Read and write access |
| 18 | + - **Custom properties**: Read and write access |
| 19 | + - **Issues**: Read and write access |
| 20 | + - **Metadata**: Read-only access |
| 21 | + - **Pull requests**: Read and write access |
| 22 | + - **Organization permissions**: |
| 23 | + - **Custom properties**: Read-only access |
| 24 | + - **Members**: Read-only access |
| 25 | +- **Subscribe to events**: Select the events your app will subscribe to. For this project, you will need to subscribe to the following events: |
| 26 | + - **Meta** |
| 27 | + - **Branch protection configuration** |
| 28 | + - **Branch protection rule** |
| 29 | + - **Exemption request push ruleset** |
| 30 | + - **Issue comment** |
| 31 | + - **Issues** |
| 32 | + - **Label** |
| 33 | + - **Member** |
| 34 | + - **Pull Request** |
| 35 | + - **Push** |
| 36 | + - **Repository** |
| 37 | + - **Repository ruleset** |
| 38 | + - **Security and analysis** |
| 39 | +- **Where can this GitHub App be installed?**: only on this account |
| 40 | + |
| 41 | +### Step 1.2: Generate a Private Key |
| 42 | +Once your app has been created, you need to create a private key for communication. Navigate to your app, which is listed in the apps section of your organization: `https://github.com/organizations/<organization>/settings/apps`.<br/><br/> |
| 43 | +Click on your app, then scroll down to the "Private keys" section. Click on "Generate a private key". This will download a `.pem` file to your computer. This file is used to authenticate your app to the GitHub Platform. Upload it to your Azure Key Vault of choice. |
| 44 | + |
| 45 | +### Step 1.3 (optional): Display information |
| 46 | +In the General settings of the GitHub App, scroll down to the Display information section. Here, you can upload an icon and a logo for your app. These images will be displayed to users when they install the app. |
| 47 | + |
| 48 | +### Step 1.4 (optional): Configure the App managers |
| 49 | +In the App managers section of the GitHub App, you can add users who will be able to manage the app. This includes users who can install the app, view the app's settings, and manage the app's permissions. You can add users by their GitHub username or full name. This is optional, but it is recommended to add at least one user who will be responsible for managing the app. |
| 50 | + |
| 51 | +### Step 1.5: Install the App |
| 52 | +In the organization settings, under the developer settings, click on GitHub Apps. Next to the GitHub App that you want to install, click Edit. Click Install App. Click Install next to the location where you want to install the GitHub App. |
| 53 | + |
| 54 | +### Step 1.6: Configure the repository access |
| 55 | +In the organization settings, under Third party-access, in the GitHub Apps section, Click on the "configure" button next to your app. In the repository access section, select **All repositories**. |
| 56 | + |
| 57 | +## Step 2: Customize the organizations labels, rulesets and properties |
| 58 | + |
| 59 | +### Step 2.1: Create the labels |
| 60 | +In the repository that will be used for onboarding (the ones that has the issue templates), navigate to the "Issues" tab. Click on "Labels". Delete all the labels. Click on "New label". Create the following labels: |
| 61 | +- **APPROVED**: Support ticket approved and will be processed (Color: #7EF299) |
| 62 | +- **COMPLETED**: Support ticket completed (Color: #0E8A16) |
| 63 | +- **FAILED**: Validation checks failed (Color: #B60205) |
| 64 | +- **OPENE**D: Support ticket opened (Color: #1D76DB) |
| 65 | +- **REJECTED**: Support ticket rejected and will be closed automatically (Color: #E99695) |
| 66 | +- **VALIDATED**: Validation checks passed and configuration as code will be created (Color: #006B75) |
| 67 | + |
| 68 | +You can also get to this page by navigating to the following page: `https://github.com/<organization>/<onboarding-repository-name>/labels` |
| 69 | + |
| 70 | +### Step 2.2: Create the custom properties |
| 71 | +In the organization settings, under Repository, click on "Custom properties". Click on **New property** for each property listed below. Replace the placeholder with your appropriate values. |
| 72 | +**Ruleset property**<br/> |
| 73 | +- **Name**: <Name>-Ruleset |
| 74 | +- **Description**: The rulesets applied to repository using the <GitHub App name> App. |
| 75 | +- **Type**: Multi select |
| 76 | + - Options: add as many as you see fit, depending on how many rulesets you plan to have. |
| 77 | + - **<GitHub App name>-Ruleset-Default**: The default ruleset that can be applied to all repositories |
| 78 | +- Check the box for **Allow repository actors to set this property**. |
| 79 | +- Check the box for **Require this property for all repositories** and pick the default value to the default value that you have set in the options above. |
| 80 | + |
| 81 | +**<Name> property**<br/> |
| 82 | +This property is used as a flag to indicate that the repository was onboarded using the GitHub App.<br/> |
| 83 | +- **Name**: <Name> |
| 84 | +- **Description**: Flag to indicate that the repository was onboarded using the <GitHub App name> App |
| 85 | +- **Type**: true/false |
| 86 | +- Check the box for **Allow repository actors to set this property**. |
| 87 | +- Check the box for **Require this property for all repositories** and pick the default value to the default value that you have set |
| 88 | + |
| 89 | +### Step 2.3: Create the rulesets |
| 90 | +In the organization settings, under Repository, click on "Rulesets". Click on "New ruleset". Select the ruleset type ou want to create whether they are branch ruleset, tag ruleset or push ruleset.<br/><br/> |
| 91 | +We strongly recommend to create a ruleset with the following configuration:<br/><br/> |
| 92 | +In Targets, under the Target repositories, pick the target **Dynamic list by property**. For the property, select the property create in Step 2.2. For the value, select the value **GitHub App**. This will ensure that the ruleset is applied to all repositories that have the property GitHub App set to GitHub App. |
0 commit comments