|
| 1 | +# Bito Action |
| 2 | + |
| 3 | +This document provides a step-by-step guide for setting up and running the Bito Action Script. The Bito Action Script allows you to configure and run automated code reviews using the Bito Code Review Agent (CRA). It enables you to seamlessly integrate the CRA into your Continuous Integration/Continuous Deployment (CI/CD) pipeline. Follow the instructions below to configure and execute the script successfully. |
| 4 | + |
| 5 | +## Steps for Setup |
| 6 | + |
| 7 | +### 1. Login to Bito |
| 8 | + |
| 9 | +- Navigate to the Bito platform: [Bito Login](https://alpha.bito.ai/auth/login). |
| 10 | +- Use your credentials to log in to your account. |
| 11 | + |
| 12 | +### 2. Create a New Agent Configuration Instance |
| 13 | + |
| 14 | +- After logging in, go to **Configured Agents**. |
| 15 | +- Select **Code Review Agent (CRA)**. |
| 16 | +- Click on **Create New Instance**. |
| 17 | + |
| 18 | +### 3. Configure the CRA Agent |
| 19 | + |
| 20 | +- **Git Access Token:** During the setup process, you'll need to provide a Git access token to allow the CRA to access your repositories. Please refer to [Bito Documentation](https://docs.bito.ai/) to create a Git access token. |
| 21 | + |
| 22 | +- **Agent Credentials:** After a successful configuration, you'll receive a unique **Agent Instance URL** and **Agent Instance Secret**. These credentials are essential for configuring the Bito Action Script. |
| 23 | + |
| 24 | +- **Webhook Configuration:** After configuring the CRA, set up the webhook in your selected Git provider. This webhook is necessary to gather analytical data, such as acceptance rates and feedback. Please refer to [Webhook Configuration Documentation](https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-as-a-self-hosted-service/install-run-via-webhooks-service#webhook-setup-guide). |
| 25 | + |
| 26 | +### 4. Download Bito Action Script |
| 27 | + |
| 28 | +- Download the Bito Action Script and a sample configuration file from the following repository: [Bito Action Script on GitHub](https://github.com/gitbito/CodeReviewAgent/tree/main/bito-action-script). |
| 29 | + |
| 30 | +### 5. Update the Property File |
| 31 | + |
| 32 | +- Open the `bito_action.properties` file located in the downloaded script folder. |
| 33 | +- Update the following properties with the information provided during the CRA configuration: |
| 34 | + |
| 35 | + - agent_instance_url=<your_agent_instance_url> |
| 36 | + - agent_instance_secret=<your_agent_instance_secret> |
| 37 | + - pr_url=<your_git_repository_url> (Optional if using the runtime URL method) |
| 38 | + |
| 39 | +### 6. Run the Bito Action Script |
| 40 | + |
| 41 | +You can run the Bito Action Script in two different ways, depending on your preference: |
| 42 | + |
| 43 | +#### Option 1: Using the Property File and Runtime Git URL |
| 44 | + |
| 45 | +- Ensure the `bito_action.properties` file is updated with the correct values. |
| 46 | +- Run the following command: |
| 47 | + |
| 48 | + ```bash |
| 49 | + bash ./bito_actions.sh bito_action.properties pr_url=<pr_url> |
| 50 | + ``` |
| 51 | + - Replace <pr_url> with the pull request URL you want to review. |
| 52 | + |
| 53 | +#### Option 2: Using Runtime Values |
| 54 | + |
| 55 | +- Provide all necessary values directly in the command line: |
| 56 | + |
| 57 | + ```bash |
| 58 | + bash ./bito_actions.sh agent_instance_url=<agent_instance_url> agent_instance_secret=<secret> pr_url=<pr_url> |
| 59 | + ``` |
| 60 | + - Replace <agent_instance_url>, <secret>, and <pr_url> with your specific values. |
| 61 | + |
| 62 | +### 7. Integrate Bito Action Script into CI/CD Pipeline |
| 63 | + |
| 64 | +- Incorporate the Bito Action Script into your CI/CD pipeline by including the appropriate commands in your build or deployment scripts. |
| 65 | + |
| 66 | +- This integration ensures that code reviews are automatically triggered as part of the pipeline, enhancing your development workflow by enforcing code quality checks on every code change. |
| 67 | + |
| 68 | +## Script Responses |
| 69 | + |
| 70 | +During execution, the script will return various responses based on the success or failure of the process. Below are the possible responses: |
| 71 | + |
| 72 | +### 1. Success |
| 73 | +**Response:** |
| 74 | +```plaintext |
| 75 | +Success:- Job Started with Id : ce82fae8-05da-4389-bddc-86ed583ab053 |
| 76 | +
|
| 77 | +``` |
| 78 | +### 2. Invalid Secret |
| 79 | +**Response:** |
| 80 | +```plaintext |
| 81 | +{"status":1,"response":"Secret is not valid","created":"2024-08-09T12:32:23.060340616Z"} |
| 82 | +
|
| 83 | +``` |
| 84 | +### 3. Invalid Instance URL |
| 85 | +**Response:** |
| 86 | +```plaintext |
| 87 | +{"status":1,"response":"webhook is invalid: Please create a new instance","created":"2024-08-09T12:33:07.050869506Z"} |
| 88 | +
|
| 89 | +``` |
| 90 | +### 4. Missing Input Data for Script |
| 91 | +**Response:** |
| 92 | +```plaintext |
| 93 | +Error: pr_url is empty |
| 94 | +
|
| 95 | +``` |
| 96 | + |
| 97 | +## Example Property File |
| 98 | + |
| 99 | +Below is a sample `bito_action.properties` file: |
| 100 | +```plaintext |
| 101 | +agent_instance_url=your_agent_instance_url |
| 102 | +agent_instance_secret=your_agent_secret |
| 103 | +pr_url= |
| 104 | +
|
| 105 | +``` |
| 106 | + |
| 107 | +## Conclusion |
| 108 | + |
| 109 | +You are now ready to use the Bito Action Script for automated code reviews through CI/CD Pipelines. Ensure all configurations are correct before running the script. If you encounter any issues, consult the [Bito Documentation](https://docs.bito.ai/) or reach out to Bito support for assistance. |
| 110 | + |
| 111 | + |
| 112 | + |
0 commit comments