STNG-145 Fix non-PR build: do not use PR parameters #476
Workflow file for this run
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: Conformance-Gateway CI | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
IN_PR: ${{ (github.event_name == 'pull_request') }} # SonarCloud | |
SONAR_PARAMS: -Dsonar.branch.name=$BRANCH_NAME | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- dev | |
- test | |
- master | |
pull_request: | |
branches: | |
- dev | |
- test | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
path: Conformance-Gateway | |
submodules: recursive | |
# Number of commits to fetch. 0 indicates all history for all branches and tags, for SonarCloud. | |
fetch-depth: 0 | |
- name: Set up Java JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 21 | |
cache: 'maven' | |
- name: Print commit sha | |
shell: bash | |
env: | |
COMMIT_SHA: ${{ github.event.pull_request.head.sha }} | |
run: | | |
echo "sha: $COMMIT_SHA" | |
- name: Build and test Conformance-Gateway | |
run: | | |
cd Conformance-Gateway | |
mvn verify -U -B -V --fail-at-end | |
- name: Set Sonar settings for PR build | |
if: ${{ env.IN_PR == 'true' }} | |
run: | | |
echo "SONAR_PARAMS=-Dsonar.pullrequest.base=dev -Dsonar.pullrequest.key=${{github.event.pull_request.number}} -Dsonar.pullrequest.branch=$BRANCH_NAME" >> $GITHUB_ENV | |
- name: Run SonarCloud analysis | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # SonarCloud | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # SonarCloud | |
run: | | |
cd Conformance-Gateway | |
mvn sonar:sonar -B ${{env.SONAR_PARAMS}} |