To get started with the GitHub application, follow these steps:
-
Clone the repository from GitHub using the following command:
git clone https://github.com/your/repository.git
-
Change into the project directory:
cd repository
To get started with the Probot application, follow these steps:
-
Install Node.js: Ensure that you have Node.js installed on your system. You can download it from the official Node.js website at nodejs.org and follow the installation instructions for your operating system.
-
Create a Probot Application: Open your terminal or command prompt and run the following command to create a new Probot application:
Replace <app-name> with the desired name of your Probot application.
-
Configure the Application: The
npx create-probot-appcommand will guide you through a configuration wizard. Enter the required information, such as your GitHub App ID and Webhook Secret, to configure the application properly. -
Install Dependencies: Navigate to the project directory and run the following command to install the dependencies:
npm install
-
Set Up Environment Variables: After you run the probot app the first time you will be directed to a link where you will authorize your app with permissions and your env key will automatically get filled.
-
Create a GitHub App on GitHub Developer Settings with the desired name and configuration.
-
Configure the GitHub App permissions based on the requirements of the task. Recommended permissions include:
- Read & Write access to pull requests and repository contents
- Comment on pull requests
-
Set the following environment variables:
APP_ID: The ID of your GitHub AppWEBHOOK_SECRET: The secret for securing the webhook communicationGITHUB_TOKEN: The GitHub token associated with the GitHub App
Create a webhook on your GitHub repository's settings page.
-
Set the webhook URL to the publicly accessible endpoint of the GitHub application.
-
Set the webhook secret to the value of the
WEBHOOK_SECRETenvironment variable. -
Select the events that the webhook should listen to, such as
pull_request.opened,pull_request.synchronize, andpull_request.edited.
The GitHub App requires the following permissions to function properly:
- Repository Contents: Read access to retrieve the contents of the pull request files.
- Pull Requests: Read access to get information about pull requests and post comments.
- Issues: Read and Write access to post comments on pull requests.
Ensure that the GitHub App has been installed on the desired repositories and has the necessary permissions to access and interact with pull requests.
-
Create a pull request on the repository with the desired code to execute.
-
Include the command
/executein the pull request title or body. -
Ensure that the pull request contains only one changed file. The application currently supports executing code from a single file per pull request.
-
Wait for the GitHub application to process the pull request and execute the code.
-
Once the code execution is complete, the application will generate a comment on the pull request with the code output or appropriate error messages.