sonar-evidence-example #90
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: sonar-evidence-example | |
| on: | |
| workflow_dispatch: # This allows manual triggering of the workflow | |
| push: | |
| branches: | |
| - CCS-2-Additional_evidence_examples | |
| pull_request: | |
| branches: | |
| - CCS-2-Additional_evidence_examples | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| docker-build-with-sonar-evidence: | |
| runs-on: ubuntu-latest | |
| env: | |
| DOCKER_REPO: 'test-docker-local' | |
| IMAGE_NAME: 'my-very-cool-image:${{ github.run_number }}' | |
| steps: | |
| - name: Display workflow and job names | |
| run: | | |
| echo "Workflow name: $GITHUB_WORKFLOW" | |
| echo "Job name: $GITHUB_JOB" | |
| - name: Install jfrog cli | |
| id: setup-cli | |
| uses: jfrog/setup-jfrog-cli@v4 | |
| env: | |
| JF_URL: ${{ vars.ARTIFACTORY_URL }} | |
| with: | |
| oidc-provider-name: jfrog-github-oidc | |
| version: latest | |
| - uses: actions/checkout@v4 | |
| - name: Sonar scan | |
| uses: SonarSource/sonarqube-scan-action@v5 | |
| continue-on-error: true # Don't fail build on SonarCloud quality gate issues | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| with: | |
| args: > | |
| -Dsonar.projectKey=my-evidence-test-org1_evidence-example | |
| -Dsonar.organization=my-evidence-test-org1 | |
| -Dsonar.projectBaseDir=examples/sonar-scan | |
| -Dsonar.sources=. | |
| -Dsonar.inclusions=**/*.go | |
| -Dsonar.java.jdkHome=$JAVA_HOME | |
| -Dsonar.verbose=true | |
| - name: Log in to Artifactory Docker Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ vars.ARTIFACTORY_URL }} | |
| username: ${{ steps.setup-cli.outputs.oidc-user }} | |
| password: ${{ steps.setup-cli.outputs.oidc-token }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and Push Docker image | |
| uses: docker/build-push-action@v6 | |
| id: docker-build | |
| with: | |
| push: true | |
| provenance: false | |
| platforms: linux/amd64 #, linux/arm64 | |
| build-args: REPO_URL=${{ vars.JF_URL }}/example-project-docker-dev-remote | |
| tags: ${{ vars.JF_URL }}/${{ env.DOCKER_REPO }}/${{ env.IMAGE_NAME }} | |
| - name: add docker package to build | |
| run: | | |
| echo "${{ vars.JF_URL }}/${{ env.DOCKER_REPO }}/${{ env.IMAGE_NAME }}@${{ steps.docker-build.outputs.digest }}" > metadata.json | |
| jf rt build-docker-create ${{ env.DOCKER_REPO }} --image-file metadata.json --build-name $GITHUB_WORKFLOW --build-number ${{ github.run_number }} | |
| - name: Publish build info | |
| if: ${{ true }} | |
| run: | | |
| jf rt build-collect-env | |
| jf rt build-add-git | |
| jf rt build-publish | |
| - name: Create evidence | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| SONAR_REPORT_TASK_FILE: ${{ github.workspace }}/examples/sonar-scan/.scannerwork/report-task.txt | |
| run: | | |
| # Attach evidence onto build using JFrog CLI | |
| jf evd create \ | |
| --integration sonar \ | |
| --build-name $GITHUB_WORKFLOW \ | |
| --build-number "${{ github.run_number }}" \ | |
| --key "${{ secrets.EVIDENCE_SIGNING_KEY }}" \ | |
| --key-alias "${{ vars.EVIDENCE_PUBLIC_KEY_ALIAS }}" |