-
Notifications
You must be signed in to change notification settings - Fork 62
61 lines (59 loc) · 2.02 KB
/
sonarcloud-integrations.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Sonarcloud scan integrations
on:
push:
branches:
- main
paths:
- integrations/**
workflow_dispatch:
jobs:
pre-run:
outputs:
changed_integrations: ${{ steps.create-matrix.outputs.INTEGRATIONS_MATRIX }}
count_changed_integrations: ${{steps.changed-integrations.outputs.all_modified_files_count }}
name: Build Sonarcloud scan run
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get all changed integrations
id: changed-integrations
uses: tj-actions/changed-files@v45
with:
json: true
dir_names: true
dir_names_max_depth: 2
files: |
integrations/**
- name: Output changes integrations
id: create-matrix
run: |
echo ${{ steps.changed-integrations.outputs.all_changed_files }}
integrations_array=${{ steps.changed-integrations.outputs.all_changed_files }}
echo "INTEGRATIONS_MATRIX=$(jq -cn --argjson integArr $integrations_array '{integrations: $integArr}')" >> $GITHUB_OUTPUT
sonarcloud-scan:
name: Sonarcloud scan changed integrations
needs: pre-run
if: ${{ needs.pre-run.outputs.count_changed_integrations > 0 }}
strategy:
max-parallel: 5
matrix: ${{ fromJson(needs.pre-run.outputs.changed_integrations) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create integration variable
run: |
unsplit_integ="${{ matrix.integrations }}"
integration=${unsplit_integ##*/}
integration=$(echo ${integration} | tr '-' '_')
integration=$(echo ${integration} | awk '{print toupper($0)}')
echo "INTEG_NAME=${integration}" >> $GITHUB_ENV
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
SONAR_TOKEN: ${{ secrets[env.INTEG_NAME] }}
with:
projectBaseDir: ${{ matrix.integrations }}