Skip to content

Commit

Permalink
Enhacement: skips sonarcloud actions when PR form fork (NUWCDIVNPT#1351)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matte22 authored Aug 22, 2024
1 parent 9a3d020 commit d6bb7cb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/api-audit-test-coverage-response.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,29 @@ jobs:
needs: test_api
runs-on: ubuntu-latest
steps:
- name: Check if PR is from a fork
id: check_fork
run: |
if [ "${{ github.event.pull_request.head.repo.fork }}" == "true" ]; then
echo "This is a PR from a fork, skipping sonarcloud analysis."
echo "SKIP_STEP=true" >> $GITHUB_ENV
fi
- name: Checkout repository
if: env.SKIP_STEP != 'true'
uses: actions/checkout@v4
with:
fetch-depth: 0 # Important to fetch all history for accurate blame information
- name: Download lcov artifact
if: env.SKIP_STEP != 'true'
uses: actions/download-artifact@v4
with:
name: coverage-report
- name: Move lcov.info to api/source
if: env.SKIP_STEP != 'true'
run: mv lcov.info ./api/source/

- name: Analyze API with SonarCloud
if: env.SKIP_STEP != 'true'
uses: SonarSource/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/client-sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,22 @@ jobs:
name: SonarCloud Analysis client
runs-on: ubuntu-latest
steps:
- name: Check if PR is from a fork
id: check_fork
run: |
if [ "${{ github.event.pull_request.head.repo.fork }}" == "true" ]; then
echo "This is a PR from a fork, skipping sonarcloud analysis."
echo "SKIP_STEP=true" >> $GITHUB_ENV
fi
#checkout the repo
- name: Checkout repository
if: env.SKIP_STEP != 'true'
uses: actions/checkout@v4
with:
fetch-depth: 0 # Important to fetch all history for accurate blame information

- name: Analyze client with SonarCloud
if: env.SKIP_STEP != 'true'
uses: SonarSource/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
Expand Down

0 comments on commit d6bb7cb

Please sign in to comment.