Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Feb 3, 2022
1 parent 515e07e commit 19829f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v2
- name: Validate changed files
if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'allow sdk change')
run: ./.github/workflows/validate_changed_files.sh `git diff --name-only "$GITHUB_BASE_REF..$GITHUB_SHA"`
run: ./.github/workflows/validate_changed_files.sh
- uses: bazelbuild/setup-bazelisk@v1
- name: Bazel caches
uses: actions/cache@v2
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/validate_changed_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ VALID_FILE_PATHS=('pkg/plugin/sdk/v1alpha2') # Array of filepaths that are allow
# by default the only local branch will be pull/PR#/merge
# fetch only the latest commit from the 2 branches in question to avoid fetching the entire repo which could be costly

for file in "$@"; do
pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")

git fetch --depth 1 origin ${GITHUB_BASE_REF}
git fetch --depth 1 origin refs/pull/${pull_number}/head.

main_head=`git rev-parse --short origin/${GITHUB_BASE_REF}`
pr_head=${GITHUB_SHA}

echo "$main_head ... $pr_head"

git diff --name-only ${main_head}..${pr_head} | while read -r file; do
echo "FILE: $file"

# check if filepath matches a valid path. If so move to the next change
for valid_path in "${VALID_FILE_PATHS[@]}"; do
Expand Down

0 comments on commit 19829f1

Please sign in to comment.