Skip to content

run sonar conditionally #177

run sonar conditionally

run sonar conditionally #177

Workflow file for this run

name: build
on:
pull_request:
push:
branches: [ master ]
jobs:
build-gradle:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 17
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 8.2.1
- name: Gradle build
run: ./gradlew build testClasses -x check
- name: Gradle check
run: ./gradlew check jacocoTestReport
- name: Generate coverage badge
uses: cicirello/jacoco-badge-generator@v2
with:
jacoco-csv-file: build/reports/jacoco/test/jacocoTestReport.csv
generate-coverage-badge: true
generate-coverage-endpoint: true
- name: Upload build
uses: actions/upload-artifact@v3
with:
name: build-output
path: |
build/libs
build/reports
.github/badges/jacoco.svg
- name: Upload GH pages
uses: actions/upload-pages-artifact@v1
with:
path: './.github/badges'
sonar-cloud:
runs-on: ubuntu-latest
needs: build-gradle
env:
sonar_token: ${{ secrets.SONAR_TOKEN }}
if: ${{ env.sonar_token != '' }}

Check failure on line 58 in .github/workflows/build.yml

View workflow run for this annotation

GitHub Actions / build

Invalid workflow file

The workflow is not valid. .github/workflows/build.yml (Line: 58, Col: 9): Unrecognized named-value: 'env'. Located at position 1 within expression: env.sonar_token != ''
steps:
- name: Git checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/download-artifact@v3
with:
name: build-output
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 17
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 8.2.1
- name: SonarCloud analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew sonar --info
deploy-gh-pages:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: build-gradle
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1