Skip to content

Commit ed1d46e

Browse files
authored
Add files whitelist to change detection (#441)
## Problem We only want to trigger post-merge actions on some files ## Solution Implement a `DIFF_WHITELIST` env variable that is used to limit the output from `git diff` These git commands are using the feature that allows paths to be specified as positional arguments after `--` ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [x] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here)
1 parent 0f6d30f commit ed1d46e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

.github/workflows/post-merge.yaml

+7-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ permissions:
1111
jobs:
1212
detect-changes:
1313
runs-on: ubuntu-latest
14+
env:
15+
# This should be a space-separated list of paths to include when looking for changed files.
16+
# You can specify paths to specific individual files, or a folder to include everything in that folder.
17+
DIFF_WHITELIST: "docs/* path/to/folder path/to/file.ipynb"
1418
outputs:
1519
modified_notebooks: ${{ steps.set-modifications.outputs.modified_notebooks }}
1620
has_modifications: ${{ steps.set-modifications.outputs.has_modifications }}
@@ -28,7 +32,7 @@ jobs:
2832
run: |
2933
# Get list of changed .ipynb files
3034
# --diff-filter=M: Only modifications (non-deletions)
31-
CHANGED_NOTEBOOKS=$(git diff --diff-filter=M --name-only --no-renames HEAD^ HEAD | grep '\.ipynb$' || true)
35+
CHANGED_NOTEBOOKS=$(git diff --diff-filter=M --name-only --no-renames HEAD^ HEAD -- $(echo "$DIFF_WHITELIST") | grep '\.ipynb$' || true)
3236
if [ -z "$CHANGED_NOTEBOOKS" ]; then
3337
echo "No notebook modifications detected"
3438
echo "has_modifications=false" >> $GITHUB_OUTPUT
@@ -45,7 +49,7 @@ jobs:
4549
run: |
4650
# Get list of deleted .ipynb files
4751
# --diff-filter=D: Only deletions
48-
DELETED_NOTEBOOKS=$(git diff --diff-filter=D --name-only --no-renames HEAD^ HEAD | grep '\.ipynb$' || true)
52+
DELETED_NOTEBOOKS=$(git diff --diff-filter=D --name-only --no-renames HEAD^ HEAD -- $(echo "$DIFF_WHITELIST") | grep '\.ipynb$' || true)
4953
if [ -z "$DELETED_NOTEBOOKS" ]; then
5054
echo "No notebook deletions detected"
5155
echo "has_deletions=false" >> $GITHUB_OUTPUT
@@ -62,7 +66,7 @@ jobs:
6266
run: |
6367
# Get list of added .ipynb files
6468
# --diff-filter=A: Only additions
65-
ADDED_NOTEBOOKS=$(git diff --diff-filter=A --name-only --no-renames HEAD^ HEAD | grep '\.ipynb$' || true)
69+
ADDED_NOTEBOOKS=$(git diff --diff-filter=A --name-only --no-renames HEAD^ HEAD -- $(echo "$DIFF_WHITELIST") | grep '\.ipynb$' || true)
6670
if [ -z "$ADDED_NOTEBOOKS" ]; then
6771
echo "No notebook additions detected"
6872
echo "has_additions=false" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)