Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not trigger CI when .md files are changed #290

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
31 changes: 30 additions & 1 deletion .github/workflows/on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +44 to +48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be replaced with echo "skip="$all_match >> "$GITHUB_OUTPUT"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it in this way because we might need to emit some data for collection in case build is skipped. I'll check with @vmilosevic and change it accordingly.


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:
Expand All @@ -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) }}
4 changes: 4 additions & 0 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
workflow_dispatch:
push:
branches: [ "main" ]
paths-ignore:
- '**/*.md'
- '.gitignore'
- 'LICENSE'

jobs:
pre-commit:
Expand Down
Loading