diff options
author | Wouter Admiraal <wouter.admiraal@sonarsource.com> | 2021-05-14 10:09:06 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-05-14 20:03:26 +0000 |
commit | d29dcf1367ad20aff8a8df47b3c0603b76722af6 (patch) | |
tree | 97fe15e2bb271760190d5ee0f98fe84a091e3c7a | |
parent | 91b6e5d06086b5befaa3f92d765c1a7316488275 (diff) | |
download | sonarqube-d29dcf1367ad20aff8a8df47b3c0603b76722af6.tar.gz sonarqube-d29dcf1367ad20aff8a8df47b3c0603b76722af6.zip |
SONAR-14832 Use our custom GitHub Actions in the in-app tutorial
2 files changed, 49 insertions, 14 deletions
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 ( <> <DefaultProjectKey component={component} /> - <CreateYmlFile yamlTemplate={dotnetYamlTemplate(!!branchesEnabled)} /> + <CreateYmlFile yamlTemplate={yamlTemplate(!!branchesEnabled)} /> </> ); } 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 }}" /> </Fragment> `; @@ -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 }}" /> </Fragment> `; |