Skip to content

Commit

Permalink
fix(sage-monorepo): fix how PRs are checked out in Sonar cloud workfl…
Browse files Browse the repository at this point in the history
…ow (#2570)
  • Loading branch information
tschaffter authored Mar 18, 2024
1 parent 18527ae commit bc28d93
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/sonar-scan.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Scan affected projects with Sonar
name: Sonar Scan

on:
push:
branches:
Expand All @@ -11,27 +12,26 @@ on:
pull_request_target:
types: [opened, synchronize, reopened, labeled]

env:
HEAD_REF: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.ref || github.ref_name }}
HEAD_REPOSITORY: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name || github.repository }}

jobs:
sonar:
runs-on: ubuntu-latest
steps:
- name: Check if the label `sonar-scan-approved` exists
- name: Check if the label `sonar-scan-approved` exists (PR only)
if: ${{ github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'sonar-scan-approved') != true }}
run: echo "Add the label 'sonar-scan-approved' to this PR to activate Sonar scan"; exit 1
run: |
echo "WARNING: Please consider if this PR can be trusted with advanced privileges."
echo "If yes, add the label 'sonar-scan-approved' to this PR to enable Sonar scan."
exit 1
- uses: actions/checkout@v3
name: Checkout ${{ env.HEAD_REPOSITORY }}:${{ env.HEAD_REF }}
- uses: actions/checkout@v4
name: Checkout
with:
ref: ${{ env.HEAD_REF }}
repository: ${{ env.HEAD_REPOSITORY }}
# We need to fetch all branches and commits so that Nx affected has a base to compare
# against.
fetch-depth: 0

- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v3
uses: nrwl/nx-set-shas@v4

- name: Set up the dev container
env:
Expand Down

0 comments on commit bc28d93

Please sign in to comment.