# Block github merge of pull requests when Sonacloud quality gate fails

**URL:** <https://community.sonarsource.com/t/block-github-merge-of-pull-requests-when-sonacloud-quality-gate-fails/28910>\
**Category:** SonarQube Cloud\
**Created:** [July 30, 2020, 10:24pm UTC](https://community.sonarsource.com/t/block-github-merge-of-pull-requests-when-sonacloud-quality-gate-fails/28910 "2020-07-30T22:24:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_Jose](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/juan_jose/32/3668_2.png) [@Juan\_Jose](https://community.sonarsource.com/u/Juan_Jose)\
**Post date:** [July 30, 2020, 10:24pm UTC](https://community.sonarsource.com/t/block-github-merge-of-pull-requests-when-sonacloud-quality-gate-fails/28910/1 "2020-07-30T22:24:18Z")

</div>

Hello, general question, from github level, how can we block PRs from being merged if Sonarcloud scan fails ? and How do developer/author of a branch get notified when their build/quality gate fails?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![TomVanBraband](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tomvanbraband/32/46480_2.png) [@TomVanBraband](https://community.sonarsource.com/u/TomVanBraband)\
**Post date:** [August 5, 2020, 9:46am UTC](https://community.sonarsource.com/t/block-github-merge-of-pull-requests-when-sonacloud-quality-gate-fails/28910/2 "2020-08-05T09:46:20Z")

</div>

Hello @Juan_Jose,

Are you using GitHub checks? If so, you can mark the SonarCloud check as mandatory, this will make merging the PR impossible if that check fails.

If you’re not using GitHub checks could you share a bit more about your set-up?

---

<div class="post-metadata">

**Author:** ![jbougs](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jbougs/32/41974_2.png) [@jbougs](https://community.sonarsource.com/u/jbougs)\
**Post date:** [March 15, 2023, 4:25pm UTC](https://community.sonarsource.com/t/block-github-merge-of-pull-requests-when-sonacloud-quality-gate-fails/28910/3 "2023-03-15T16:25:47Z")

</div>

Hi Tom,

I am having this issue where the SC scan is failing the quality gate but the PR is not being blocked from being merged. How do I mark the SC check as mandatory?

this is what my action file step looks like:

```auto
      - name: SonarCloud Scan
        uses: SonarSource/sonarcloud-github-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

```

---

<div class="post-metadata">

**Author:** ![jbougs](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jbougs/32/41974_2.png) [@jbougs](https://community.sonarsource.com/u/jbougs)\
**Post date:** [March 15, 2023, 5:22pm UTC](https://community.sonarsource.com/t/block-github-merge-of-pull-requests-when-sonacloud-quality-gate-fails/28910/4 "2023-03-15T17:22:06Z")

</div>

Nevermind, this guide had the answer:

> [@How to block the merge of Pull Requests when SonarQube Quality Gate is failed, with GitHub](https://community.sonarsource.com/t/how-to-block-the-merge-of-pull-requests-when-sonarqube-quality-gate-is-failed-with-github/19516):
>
> This feature is available with [GitHub.com](http://GitHub.com) and GitHub Enterprise 2.17 and higher (maybe earlier versions too but this is to be verified) With GitHub it’s possible to block the merge of a pull request if the SonarQube Quality Gate is failed on the PR (Pull Request). This is called a Branch protection rule in GitHub, and can be defined per target branch, ie you can select which branches can accept pull request merges only if Quality Gate is passed. These branches are called protected branches …

---

<div class="post-metadata">

**Author:** ![TomVanBraband](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tomvanbraband/32/46480_2.png) [@TomVanBraband](https://community.sonarsource.com/u/TomVanBraband)\
**Post date:** [March 16, 2023, 7:44am UTC](https://community.sonarsource.com/t/block-github-merge-of-pull-requests-when-sonacloud-quality-gate-fails/28910/5 "2023-03-16T07:44:49Z")

</div>

Closed on March 16, 2023, 7:44am UTC


