diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 0d2fd687..0ca51ab1 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -3,17 +3,55 @@ name: Build and Publish on: push: branches: [ "master" ] + paths: + - 'gradle/wrapper/**' + - '**/*.gradle' + - '**/*.java' + - '**/*.md' + - '**/*.adoc' pull_request: branches: [ "master" ] types: [opened, synchronize, reopened] + paths: + - 'gradle/wrapper/**' + - '**/*.gradle' + - '**/*.java' + - '**/*.md' + - '**/*.adoc' permissions: contents: write pull-requests: write jobs: + check-changes: + name: Check for file changes + runs-on: ubuntu-latest + outputs: + java-changes: ${{ steps.filter.outputs.java }} + readme-changes: ${{ steps.filter.outputs.readme }} + build-changes: ${{ steps.filter.outputs.build }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + java: + - '**/*.java' + readme: + - '**/*.md' + - '**/*.adoc' + build: + - 'gradle/wrapper/**' + - '**/*.gradle' + gradle-build: name: Build project with Gradle + needs: check-changes + if: ${{ needs.check-changes.outputs.java-changes == 'true' || needs.check-changes.outputs.build-changes == 'true' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -45,6 +83,7 @@ jobs: - name: Run CI build run: ./gradlew build - name: Publish test coverage + if: ${{ needs.check-changes.outputs.java-changes == 'true' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} @@ -53,8 +92,9 @@ jobs: asciidoc-build: # The type of runner that the job will run on name: Generate articles with Ascii Doctor + needs: [check-changes, gradle-build] + if: ${{ needs.check-changes.outputs.readme-changes == 'true' }} runs-on: ubuntu-latest - needs: gradle-build # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it @@ -62,4 +102,4 @@ jobs: # Includes the AsciiDoctor GitHub Pages Action to convert adoc files to html and publish to gh-pages branch - name: asciidoctor-ghpages - uses: manoelcampos/asciidoctor-ghpages-action@v2 \ No newline at end of file + uses: manoelcampos/asciidoctor-ghpages-action@v2 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 702e5a44..a5138b42 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -14,8 +14,14 @@ name: "CodeQL" on: push: branches: [ "master" ] + paths: + - '**/*.java' + - '**/*.gradle' pull_request: branches: [ "master" ] + paths: + - '**/*.java' + - '**/*.gradle' schedule: - cron: '25 21 * * 0'