Why it says my main branch is empty

Sonarcloud reports my “main branch is empty” on the dashboard and does not report any analysis. I have setup develop branch as my main branch and analysis is reported when PR is pushed from feature branch to develop. But main branch analysis is never done.

Hey there.

How is your GitHub action configured that runs the analysis? Can you share the full .yml here?

Hi Colin,

This is the file.

name: “Sonar cloud analysis”

      - develop


    name: sonar-check
    runs-on: ubuntu-latest
      - uses: actions/checkout@v3
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: SonarCloud Scan
        uses: SonarSource/sonarcloud-github-action@master
          GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}  
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}


I’m surprised to hear that this YAML file actually results in PRs being analyzed – this would usually require a trigger like this (explicitly mentioning pull_request):

name: Build
      - develop
    types: [opened, synchronize, reopened]

Are you sure you don’t have another action file defined that is actually being used instead?

yes we have different yaml files for push and pull but instead getting this .

pull request pipeline code is .

Do you have a develop branch in your project’s Branches & Pull Requests?

@Colin yes we have develop branch .
Screenshot from 2023-10-02 20-37-38

But what about on SonarCloud?

yes we have set develop as a main branch in sonar also

And it still says your main branch is empty? It looks like it has a passing quality gate.

yes it still says project main branch is empty .

In that case, I would suggest attaching your analysis logs from your GitHub actions run here.