From b4e8c9ddfb0d2ed603588f5305150f16622502e8 Mon Sep 17 00:00:00 2001 From: Rostislav Sulejmanov <85498741+rostilos@users.noreply.github.com> Date: Fri, 17 Jan 2025 15:20:49 +0200 Subject: [PATCH 1/5] Update auth.json.sample --- auth.json.sample | 1 + 1 file changed, 1 insertion(+) diff --git a/auth.json.sample b/auth.json.sample index be1c70cfe1e18..a185c77b498db 100644 --- a/auth.json.sample +++ b/auth.json.sample @@ -6,3 +6,4 @@ } } } + From c5ab1153ae9c60e0e55fac9bb343ccb7e3b4313d Mon Sep 17 00:00:00 2001 From: Rostislav Sulejmanov <85498741+rostilos@users.noreply.github.com> Date: Fri, 17 Jan 2025 15:32:04 +0200 Subject: [PATCH 2/5] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e6b113f073eef..c2a270bf57abc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: - uses: sonarsource/sonarqube-scan-action@v3 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ variables.SONAR_HOST_URL }} + SONAR_HOST_URL: ${{ env.SONAR_HOST_URL }} - uses: sonarsource/sonarqube-quality-gate-action@master timeout-minutes: 5 env: From 1b8e2b62737515db0f2059d97c57cf9dbcde3965 Mon Sep 17 00:00:00 2001 From: Rostislav Sulejmanov <85498741+rostilos@users.noreply.github.com> Date: Fri, 17 Jan 2025 15:36:09 +0200 Subject: [PATCH 3/5] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c2a270bf57abc..f5e330c85843e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: - uses: sonarsource/sonarqube-scan-action@v3 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ env.SONAR_HOST_URL }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - uses: sonarsource/sonarqube-quality-gate-action@master timeout-minutes: 5 env: From 74e47e85df57958368a8f27781a0b3b599823735 Mon Sep 17 00:00:00 2001 From: Rostislav Sulejmanov <85498741+rostilos@users.noreply.github.com> Date: Fri, 17 Jan 2025 15:50:57 +0200 Subject: [PATCH 4/5] Update build.yml --- .github/workflows/build.yml | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f5e330c85843e..16d097fdb0401 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,25 +1,51 @@ name: Build on: - pull_request: - types: [opened, reopened, synchronize] - branches: - - 'sonarqube' + issue_comment: + types: [created] jobs: build: - name: Build and analyze + name: SonarQube analyze + if: github.event.issue.pull_request && contains(github.event.comment.body, '/sonar') runs-on: ubuntu-latest steps: + - name: Get PR branch + uses: xt0rted/pull-request-comment-branch@v1 + id: comment-branch + + - name: Checkout PR branch - uses: actions/checkout@v4 with: + ref: ${{ steps.comment-branch.outputs.head_ref }} fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + + - name: SonarQube Scan - uses: sonarsource/sonarqube-scan-action@v3 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + + - name: SonarQube Quality Gate - uses: sonarsource/sonarqube-quality-gate-action@master timeout-minutes: 5 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + - name: Add comment to PR + uses: actions/github-script@v6 + if: always() + with: + script: | + const name = '${{ github.workflow }}'; + const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'; + const success = '${{ job.status }}' === 'success'; + const body = `${name}: ${success ? 'succeeded ✅' : 'failed ❌'}\n${url}`; + + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: body + }) From 94f2767d1d675adb163f9f674496831f77ea7f7f Mon Sep 17 00:00:00 2001 From: Rostislav Sulejmanov <85498741+rostilos@users.noreply.github.com> Date: Fri, 17 Jan 2025 15:51:48 +0200 Subject: [PATCH 5/5] Update build.yml --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 16d097fdb0401..601e07d338abe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Get PR branch - uses: xt0rted/pull-request-comment-branch@v1 + - uses: xt0rted/pull-request-comment-branch@v1 id: comment-branch - name: Checkout PR branch @@ -34,7 +34,7 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - name: Add comment to PR - uses: actions/github-script@v6 + - uses: actions/github-script@v6 if: always() with: script: |