Skip to content

Commit 1635ad4

Browse files
committed
Use a while loop instead
1 parent 7f6bc29 commit 1635ad4

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

.github/workflows/lint_changed_files.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,17 @@ jobs:
8282
id: changed-files
8383
run: |
8484
if [ -n "${{ github.event.pull_request.number }}" ]; then
85-
# Get the list of changed files in pull request via the GitHub API. We use `awk` to get the value of the link header with the URL for the next page of results, and keep requesting next pages until all the files are retrieved:
86-
files=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ github.event.pull_request.number }}/files?page=1&per_page=100" -D - | awk '{if (match($0, "Link:")){print}}' | awk '{print $2}' | tr -d '<>' | tr -d ',' | xargs -I {} curl -s -H "Accept: application/vnd.github.v3+json" {} | jq -r '.[] | .filename')
85+
# Get the list of changed files in pull request via the GitHub API:
86+
page=1
87+
files=""
88+
while true; do
89+
new_files=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ github.event.pull_request.number }}/files?page=$page&per_page=100" | jq -r '.[] | .filename')
90+
if [ -z "$new_files" ]; then
91+
break
92+
fi
93+
files="$files $new_files"
94+
page=$((page+1))
95+
done
8796
else
8897
# Get changed files by comparing the current commit to the commit before the push event:
8998
files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})

0 commit comments

Comments
 (0)