diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index b7a72c9..8d7f174 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -21,8 +21,35 @@ jobs: spdx: uses: ./.github/workflows/spdx.yml secrets: inherit + + check-files: + runs-on: ubuntu-latest + outputs: + skip: ${{ steps.check.outputs.skip }} + steps: + - name: Check if ignored files are modified + id: check + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + run: | + CHANGED_FILES=$(gh pr diff ${{ github.event.pull_request.number }} --name-only --repo ${{ github.repository }}) + all_match=true + for file in $CHANGED_FILES; + do + if [[ ! $file =~ ^.*\.(md|gitignore)$ && $file != *"LICENSE"* ]]; then + all_match=false + break + fi + done + if [ "$all_match" = true ]; then + echo "skip=true" >> "$GITHUB_OUTPUT" + else + echo "skip=false" >> "$GITHUB_OUTPUT" + fi + build-and-test: - needs: [pre-commit, spdx] + needs: [pre-commit, spdx, check-files] + if: ${{ needs.check-files.outputs.skip == 'false' }} uses: ./.github/workflows/build-and-test.yml secrets: inherit with: @@ -34,10 +61,12 @@ jobs: needs: - pre-commit - spdx + - check-files - build-and-test runs-on: Ubuntu-latest steps: - name: Check if the needed jobs succeeded or failed uses: re-actors/alls-green@release/v1 with: + allowed-skips: build-and-test jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml index 3c9be34..ea6280e 100644 --- a/.github/workflows/on-push.yml +++ b/.github/workflows/on-push.yml @@ -4,6 +4,10 @@ on: workflow_dispatch: push: branches: [ "main" ] + paths-ignore: + - '**/*.md' + - '.gitignore' + - 'LICENSE' jobs: pre-commit: