Skip to content

Commit

Permalink
build: fix changed-file-validation to allow PRs from forks
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Feb 3, 2022
1 parent ec919b0 commit 6bc9f83
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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 ${{ github.head_ref }} ${{ github.base_ref }}
run: ./.github/workflows/validate_changed_files.sh
- uses: bazelbuild/setup-bazelisk@v1
- name: Bazel caches
uses: actions/cache@v2
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/validate_changed_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ 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
git fetch --depth 1 origin "$1"
git fetch --depth 1 origin "$2"

git diff "origin/$1..origin/$2" --name-only | while read -r file; do
git fetch --depth 1 origin "${GITHUB_BASE_REF}"
git fetch --depth 1 origin "${GITHUB_REF}"

git diff --name-only "origin/${GITHUB_BASE_REF}..${GITHUB_SHA}" | while read -r file; do

# 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 6bc9f83

Please sign in to comment.