Compare two branches without pull-request

Template for a good new topic, formatted with Markdown:

  • ALM used: GitHub
  • CI system used: Github Actions
  • Languages of the repository: Golang

Hello there.
I’ve been integrating Sonar with Github Actions, and I found out a situation I cannot overcome.
I want to compare two branches, but without a Pull-Request.

My CI/CD within Sonar setup is the following:

  • my main branch is the long-lived one
  • we work with dev branch (witch is more or less our pre-production), and branches per squad
  • the flow: we send our code from feature branches to squad branches through PRs
  • we make all the tests using squad branches
  • we integrate squad branches to dev
  • once we are ready to deploy in prod, we send code from dev to main

That said, sometimes I going to create a PR from squad branch → dev and request for review (and on this case, run SonarCloud based on PR). However sometimes I just want to send my code from my squad branch directly to dev (on this case, I also want to run sonar comparing squad branch to dev branch).

I couldn’t find any example using sonarcloud github action. I am not even sure if that is possible, or if I should somehow handle this with github.

Thanks in advance!

Hey there.

You could analyze a short-lived branch targeting the squad branch with sonar.branch.target.