'How to stop GitHub Action build when SonarQube scan fails

I have a scan step built into my GitHub Action build and that is working fine. I reach out to my company's SonarQub instance and the scan is initiated. The problem I am having is trying to stop a build if there is a failure. For the life of me I can't seem to find a way to do that. Also, when I watch the scan it appears as though the next steps might be happening before it finishes (not positive on that but thought I would mention it). Any ideas??

name: Build, test, & deploy
on: [push]
jobs:
  sonarqube:
      runs-on: ubuntu-latest
      steps:
      - uses: actions/checkout@v2
        with:
          # Disabling shallow clone is recommended for improving relevancy of reporting
          fetch-depth: 0
        # Triggering SonarQube analysis as results of it are required by Quality Gate check
      - name: SonarQube Scan
        uses: sonarsource/sonarqube-scan-action@master
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
      - name: SonarQube Quality Gate check
        uses: sonarsource/sonarqube-quality-gate-action@master
        # Force to fail step after specific time
        timeout-minutes: 5
        env:
         SONAR_TOKEN: ${{ secrets.ADAM_SONAR_TOKEN }}
  build:
    name:  Project build & package
    if: "!contains(github.even.head_commit.message, '[skip-ci]')"
    runs-on: ubuntu-latest
    env:
      #environment var for this job
      #### the rest of the build is below this area - I didn't think it was necessary to include



Solution 1:[1]

The answer is using "needs": https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds

Solution 2:[2]

You should use needs in your build job:

build:
    needs: sonarqube
    name:  Project build & package

You can find information here: https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AdamCodes716
Solution 2 Developer