From d29dcf1367ad20aff8a8df47b3c0603b76722af6 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Fri, 14 May 2021 10:09:06 +0200 Subject: SONAR-14832 Use our custom GitHub Actions in the in-app tutorial --- .../tutorials/github-action/commands/Others.tsx | 38 ++++++++++++++++++---- .../__tests__/__snapshots__/Others-test.tsx.snap | 25 ++++++++++---- 2 files changed, 49 insertions(+), 14 deletions(-) (limited to 'server') diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx index b2de4454b8b..11320042f68 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/Others.tsx @@ -26,12 +26,20 @@ export interface OthersProps { component: T.Component; } -const dotnetYamlTemplate = (branchesEnabled: boolean) => `name: Build +const yamlTemplate = (branchesEnabled: boolean) => { + let output = `name: Build on: push: branches: - - master # or the name of your main branch -${branchesEnabled ? ' pull_request:\n types: [opened, synchronize, reopened]' : ''} + - master # or the name of your main branch`; + + if (branchesEnabled) { + output += ` + pull_request: + types: [opened, synchronize, reopened]`; + } + + output += ` jobs: build: name: Build @@ -40,18 +48,34 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - uses: docker://sonarsource/sonar-scanner-cli:latest + - uses: sonarsource/sonarqube-scan-action@master env: - GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}`; + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }} + # If you wish to fail your job when the Quality Gate is red, uncomment the + # following lines. This would typically be used to fail a deployment.`; + + if (branchesEnabled) { + output += ` + # We do not recommend to use this in a pull request. Prefer using pull request + # decoration instead.`; + } + + output += ` + # - uses: sonarsource/sonarqube-quality-gate-action@master + # timeout-minutes: 5 + # env: + # SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }}`; + + return output; +}; export default function Others(props: OthersProps) { const { component, branchesEnabled } = props; return ( <> - + ); } diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Others-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Others-test.tsx.snap index 27415bab1ff..7fe6d432e9c 100644 --- a/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Others-test.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/github-action/commands/__tests__/__snapshots__/Others-test.tsx.snap @@ -42,11 +42,18 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - uses: docker://sonarsource/sonar-scanner-cli:latest + - uses: sonarsource/sonarqube-scan-action@master env: - GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}" + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }} + # If you wish to fail your job when the Quality Gate is red, uncomment the + # following lines. This would typically be used to fail a deployment. + # We do not recommend to use this in a pull request. Prefer using pull request + # decoration instead. + # - uses: sonarsource/sonarqube-quality-gate-action@master + # timeout-minutes: 5 + # env: + # SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }}" /> `; @@ -83,7 +90,6 @@ on: push: branches: - master # or the name of your main branch - jobs: build: name: Build @@ -92,11 +98,16 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - uses: docker://sonarsource/sonar-scanner-cli:latest + - uses: sonarsource/sonarqube-scan-action@master env: - GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}" + SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }} + # If you wish to fail your job when the Quality Gate is red, uncomment the + # following lines. This would typically be used to fail a deployment. + # - uses: sonarsource/sonarqube-quality-gate-action@master + # timeout-minutes: 5 + # env: + # SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }}" /> `; -- cgit v1.2.3