diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..45f970a --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,30 @@ +name: Build + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + name: Build and analyze + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - uses: sonarsource/sonarqube-scan-action@v4 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + 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@v1 + # timeout-minutes: 5 + # env: + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml deleted file mode 100644 index 812979c..0000000 --- a/.github/workflows/pullrequest.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Pull Request - -on: pull_request_target - -jobs: - sonarQubeTrigger: - name: SonarQube Trigger - runs-on: self-hosted - steps: - - uses: actions/checkout@master - with: - fetch-depth: 0 - - name: SonarQube Scan - uses: philips-software/sonar-scanner-action@main - with: - url: ${{ secrets.SONARQUBE_HOST }} - token: ${{ secrets.SONARQUBE_TOKEN }} - projectKey: github-action-scripts - projectName: GitHub Action Scripts - enablePullRequestDecoration: true - - name: Cleanup scan - run: sudo rm -rf "$GITHUB_WORKSPACE/.scannerwork" diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml deleted file mode 100644 index 4bea56e..0000000 --- a/.github/workflows/push.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: PushAction - -on: - push: - branches: [ main, master ] - paths-ignore: - - .github/workflows/pullrequest.yml - workflow_dispatch: - -jobs: - build: - runs-on: [ self-hosted ] - steps: - - name: Cancel previous runs - uses: n1hility/cancel-previous-runs@v2 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Fetch git repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: SonarQube Scan - uses: philips-software/sonar-scanner-action@main - with: - url: ${{ secrets.SONARQUBE_HOST }} - token: ${{ secrets.SONARQUBE_TOKEN }} - projectKey: github-action-scripts - projectName: GitHub Action Scripts - - - name: Cleanup scan - run: sudo rm -rf "$GITHUB_WORKSPACE/.scannerwork" diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..06fe704 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1 @@ +sonar.projectKey=linaro-its_github-action-scripts_9b2d2212-afd9-4e77-9031-4fdaa073508f