Github actions set environment on a top level in workflow

20 views Asked by At

I am making a pipeline using github actions and when the part to connect to sonar qube comes up it says that the github secrets are blank, and I know for a fact they are not, if I hard code the values in the places of the secrets it works normally without an error so that means that the sonar qube is runnning properly. This is the code:

 farmer-sonarqube:
    name: Farmer Module - Compile, Test, Analyze, and Quality Gate Check
    runs-on: self-hosted
    needs: complete-build-test-analysis
    steps:
      - name: Compile, Test, and Analyze Farmer Module
        run: |
          mvn -f ./farmer/pom.xml clean compile test sonar:sonar \
            -Dsonar.projectKey=Flowcontrol_Farmer_Module \
            -Dsonar.projectName="Flowcontrol - Farmer Module" \
            -Dsonar.host.url=${{ vars.SONAR_HOST_STAGING_URL }} \
            -Dsonar.token=${{ secrets.SONAR_TOKEN_STAGING }}
      - name: SonarQube Quality Gate Check - Farmer Module
        id: sonarqube-quality-gate-check-farmer
        uses: sonarsource/sonarqube-quality-gate-action@master
        with:
          scanMetadataReportFile: ./farmer/target/sonar/report-task.txt
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_STAGING }}
          SONAR_HOST_URL: ${{ vars.SONAR_HOST_STAGING_URL }}
        #continue-on-error: true

enter image description here

enter image description here

When I add the environment: staging to each of the jobs it works and it finds the secrets but the thing is that I have slack connect to it and on every trigger it sends a notification to it. I have 4 jobs that do that and it is annoying to get notifications for each of them. Is it possible to specify on a top level that this workflow is for the staging environment so I will get a message once on slack saying that the workflow started and then succeeded/failed depending of the outcome?

0

There are 0 answers