Merge pull request #373 from bia-technologies/feature/372 #911
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SonarQualityGate | |
on: | |
- push | |
- pull_request_target | |
jobs: | |
SonarQualityGate: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.event.repository.full_name | |
steps: | |
- name: Checkout PR | |
if: github.event_name != 'push' | |
uses: actions/checkout@v4 | |
with: | |
ref: refs/pull/${{ github.event.number }}/merge # Для поддержки pull_request и pull_request_target | |
- name: Checkout ${{ github.ref_name }} | |
if: github.event_name == 'push' | |
uses: actions/checkout@v4 | |
- name: Configure env vars for SonarCloud scan | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
run: | | |
echo "::set-env name=PATH::/opt/sonar-scanner/bin:$PATH" | |
- name: Extract version | |
if: github.event_name == 'push' | |
shell: bash | |
run: echo "version=$(cat ./exts/yaxunit/src/Configuration/Configuration.mdo | grep -oP '(?<=<version>)[\d.]+')" >> $GITHUB_OUTPUT | |
id: extract_version | |
- name: Setup sonarqube | |
uses: warchant/setup-sonar-scanner@v8 | |
# Анализ проекта в SonarQube (ветка) | |
- name: Анализ в SonarQube (${{ github.ref_name }}) | |
if: github.event_name == 'push' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: sonar-scanner | |
-Dsonar.host.url=https://sonar.openbsl.ru | |
-Dsonar.branch.name=${{ github.ref_name }} | |
-Dsonar.projectVersion=${{ steps.extract_version.outputs.version }} | |
-Dsonar.qualitygate.wait=true | |
-Dsonar.qualitygate.timeout=300 | |
# Анализ проекта в SonarQube (PR) | |
# https://docs.sonarqube.org/latest/analysis/pull-request/ | |
- name: Анализ в SonarQube (pull-request ${{ github.event.number }}) | |
if: github.event_name != 'push' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: sonar-scanner | |
-Dsonar.host.url=https://sonar.openbsl.ru | |
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }} | |
-Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} | |
-Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }} | |
-Dsonar.scm.revision=${{ github.event.pull_request.head.sha }} | |
-Dsonar.qualitygate.wait=true | |
-Dsonar.qualitygate.timeout=300 | |
- name: Publish report (pull-request) | |
if: github.event_name != 'push' && (success()||failure()) | |
uses: 1CDevFlow/sonar-review-action@main | |
with: | |
sonar_branch_plugin: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |