Skip to content

Commit cd28ac4

Browse files
committed
build: Avoid using GitHub API
1 parent 3d01193 commit cd28ac4

3 files changed

Lines changed: 10 additions & 25 deletions

File tree

.github/workflows/run_affected_benchmarks.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ on:
2626
# List paths for which changes should trigger this workflow:
2727
- 'lib/**/benchmark/**'
2828

29-
pull_request_target:
29+
pull_request:
3030
types:
3131
- opened
3232
- synchronize
@@ -53,6 +53,7 @@ jobs:
5353
- name: 'Checkout repository'
5454
uses: actions/checkout@v3
5555
with:
56+
5657
# Specify whether to remove untracked files before checking out the repository:
5758
clean: true
5859

.github/workflows/run_affected_examples.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727
- 'lib/**/examples/**'
2828
- 'lib/**/README.md'
2929

30-
pull_request_target:
30+
pull_request:
3131
types:
3232
- opened
3333
- synchronize
@@ -89,17 +89,9 @@ jobs:
8989
id: changed-files
9090
run: |
9191
if [ -n "${{ github.event.pull_request.number }}" ]; then
92-
# Get the list of changed files in pull request via the GitHub API:
93-
page=1
94-
files=""
95-
while true; do
96-
new_files=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ github.event.pull_request.number }}/files?page=$page&per_page=100" | jq -r '.[] | select(.status == "modified" or .status == "added") | .filename')
97-
if [ -z "$new_files" ]; then
98-
break
99-
fi
100-
files="$files $new_files"
101-
page=$((page+1))
102-
done
92+
# Get the list of changed files in pull request:
93+
ancestor_commit=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
94+
files=$(git diff --diff-filter=AM --name-only $ancestor_commit ${{ github.event.pull_request.head.sha }})
10395
else
10496
# Get changed files by comparing the current commit to the commit before the push event or with its parent:
10597
if [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]; then

.github/workflows/run_affected_tests.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ on:
4141
# List paths for which changes should *not* trigger this workflow:
4242
- '!lib/**/_tools/**'
4343

44-
pull_request_target:
44+
pull_request:
4545
types:
4646
- opened
4747
- synchronize
@@ -123,17 +123,9 @@ jobs:
123123
id: changed-directories
124124
run: |
125125
if [ -n "${{ github.event.pull_request.number }}" ]; then
126-
# Get the list of changed files in pull request via the GitHub API:
127-
page=1
128-
files=""
129-
while true; do
130-
new_files=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ github.event.pull_request.number }}/files?page=$page&per_page=100" | jq -r '.[] | select(.status == "modified" or .status == "added") | .filename')
131-
if [ -z "$new_files" ]; then
132-
break
133-
fi
134-
files="$files $new_files"
135-
page=$((page+1))
136-
done
126+
# Get the list of changed files in pull request:
127+
ancestor_commit=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
128+
files=$(git diff --diff-filter=AM --name-only $ancestor_commit ${{ github.event.pull_request.head.sha }})
137129
else
138130
# Get changed files by comparing the current commit to the commit before the push event or with its parent:
139131
if [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]; then

0 commit comments

Comments
 (0)