# Setting up GitHub integration for your project

## Setting up pull request integration <a href="#pull-request-integration" id="pull-request-integration"></a>

For bound projects (projects created by importing the GitHub repository), pull request decoration is supported in GitHub provided the pull request analysis has been properly set up in your project. See [setting-up-the-pull-request-analysis](https://docs.sonarsource.com/sonarqube-server/analyzing-source-code/pull-request-analysis/setting-up-the-pull-request-analysis "mention").

You can bind an existing and manually created project to its GitHub repository provided the global integration of SonarQube Server with GitHub has been properly set up. To do so, see [changing-project-binding](https://docs.sonarsource.com/sonarqube-server/project-administration/maintaining-project/changing-project-binding "mention").

## Disabling the analysis summary in GitHub Conversation tab <a href="#disable-summary-in-conversation-tab" id="disable-summary-in-conversation-tab"></a>

By default, SonarQube Server shows the analysis summary in the Conversation and Checks tab of your GitHub pull requests.

To disable the summary in the Conversation tab, in SonarQube Server, go to *Your project* > **Project Settings** > **General Settings** > **DevOps Platform Integration** and unselect **Enable analysis summary under the GitHub Conversation tab**.

## Preventing pull request merges when the quality gate fails <a href="#preventing-pull-request-merges" id="preventing-pull-request-merges"></a>

SonarQube Cloud adds the quality gate status as a GitHub check. To block pull requests from being merged if it is failing the quality gate, define on your branch a ruleset (recommended) or a protection rule.

#### With a branch ruleset <a href="#with-a-branch-ruleset" id="with-a-branch-ruleset"></a>

1. In GitHub, go to your repository **Settings** and select **Rules** > **Rulesets** under **Code and automation**.
2. Create a new branch ruleset (or edit an existing one).
3. In the **Target branches** section, select **Add a target**, and define the name pattern of the branches you want to target. For more information, see the [GitHub documentation](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/creating-rulesets-for-a-repository).
4. In the **Branch protections** section, select **Require status checks to pass.**
5. In the additional settings, select **Require branches to be up to date before merging.**
6. In **Status checks that are required**, select **Add checks**.
7. Find  `SonarQube Code Analysis` and add it to the list of required checks.
8. Terminate the ruleset creation.

#### With a branch protection rule <a href="#with-a-branch-protection-rule" id="with-a-branch-protection-rule"></a>

1. In GitHub, go to your repository **Settings** > **Branches** > **Branch protection rules** and select either the **Add rule** or **Edit** button if you already have a rule on the branch you wish to protect.
2. Complete the **Branch protection rule** form:
   * Define the **Branch name pattern** (the name of the branch you wish to protect)
   * Select **Require status checks to pass before merging** to open supplementary form fields.
   * In the **Search for status checks in the last week** for this repository field, select **Require branches to be up to date before merging**, then find `SonarQube Code Analysis`  and add it to the list of required checks.
3. Terminate the protection rule creation.

## Related pages

* [github](https://docs.sonarsource.com/sonarqube-server/user-guide/issues/in-devops-platform/github "mention")
