run sonar conditionally #177
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: 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 GitHub Actions / buildInvalid workflow file
|
||
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 |