You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Others.tsx 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import * as React from 'react';
  21. import { Component } from '../../../../types/types';
  22. import CreateYmlFile from '../../components/CreateYmlFile';
  23. import DefaultProjectKey from '../../components/DefaultProjectKey';
  24. import { GITHUB_ACTIONS_RUNS_ON_LINUX } from '../constants';
  25. import { generateGitHubActionsYaml } from '../utils';
  26. import MonorepoDocLinkFallback from './MonorepoDocLinkFallback';
  27. export interface OthersProps {
  28. branchesEnabled?: boolean;
  29. mainBranchName: string;
  30. monorepo?: boolean;
  31. component: Component;
  32. }
  33. function otherYamlSteps(branchesEnabled: boolean) {
  34. let output = `
  35. - uses: sonarsource/sonarqube-scan-action@master
  36. env:
  37. SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }}
  38. SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}
  39. # If you wish to fail your job when the Quality Gate is red, uncomment the
  40. # following lines. This would typically be used to fail a deployment.`;
  41. if (branchesEnabled) {
  42. output += `
  43. # We do not recommend to use this in a pull request. Prefer using pull request
  44. # decoration instead.`;
  45. }
  46. output += `
  47. # - uses: sonarsource/sonarqube-quality-gate-action@master
  48. # timeout-minutes: 5
  49. # env:
  50. # SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }}`;
  51. return output;
  52. }
  53. export default function Others(props: OthersProps) {
  54. const { component, branchesEnabled, mainBranchName, monorepo } = props;
  55. return (
  56. <>
  57. <DefaultProjectKey component={component} monorepo={monorepo} />
  58. {monorepo ? (
  59. <MonorepoDocLinkFallback />
  60. ) : (
  61. <CreateYmlFile
  62. yamlFileName=".github/workflows/build.yml"
  63. yamlTemplate={generateGitHubActionsYaml(
  64. mainBranchName,
  65. !!branchesEnabled,
  66. GITHUB_ACTIONS_RUNS_ON_LINUX,
  67. otherYamlSteps(!!branchesEnabled),
  68. )}
  69. />
  70. )}
  71. </>
  72. );
  73. }