Skip to content

Commit e102e98

Browse files
committed
Use mapfile w/ git diff for CI checks
1 parent 7ffef92 commit e102e98

3 files changed

Lines changed: 22 additions & 28 deletions

File tree

.github/workflows/main.yml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v2
10+
with:
11+
fetch-depth: 0
1012

1113
- name: download checker
1214
uses: wei/wget@v1
@@ -15,25 +17,15 @@ jobs:
1517

1618
- run: sudo chmod +x ./checker
1719

18-
- name: find PR
19-
id: pr
20-
run: |
21-
number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
22-
echo "##[set-output name=number;]$number"
23-
24-
- name: find modified packages
25-
id: diff
26-
uses: dorner/file-changes-action@v1.2.0
27-
with:
28-
githubToken: ${{ secrets.GITHUB_TOKEN }}
29-
plaintext: true
30-
prNumber: ${{ steps.pr.outputs.number }}
31-
3220
- name: lint package
3321
id: lint
34-
run: bash ./scripts/lint.sh \
35-
${{ steps.diff.outputs.files_modified }} \
36-
${{ steps.diff.outputs.files_added }}
22+
run: |
23+
mapfile -d '' files < <(
24+
git diff --name-only -z \
25+
"${{ github.event.pull_request.base.sha }}" \
26+
"${{ github.event.pull_request.head.sha }}"
27+
)
28+
bash ./scripts/lint.sh "${files[@]}"
3729
3830
# install glob
3931
- uses: actions/checkout@v2
@@ -47,6 +39,10 @@ jobs:
4739
env:
4840
DOCKER_IMAGE: ghcr.io/cdnjs/tools:cf63aa8265f012629ca4dad9d431f90311d68bcc2
4941
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50-
run: bash ./scripts/show-files.sh \
51-
${{ steps.diff.outputs.files_modified }} \
52-
${{ steps.diff.outputs.files_added }}
42+
run: |
43+
mapfile -d '' files < <(
44+
git diff --name-only -z \
45+
"${{ github.event.pull_request.base.sha }}" \
46+
"${{ github.event.pull_request.head.sha }}"
47+
)
48+
bash ./scripts/show-files.sh "${files[@]}"

scripts/lint.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
set -e
2-
files="$@"
1+
set -euo pipefail
32

4-
for f in $files
3+
for f in "$@"
54
do
65
if [ "${f##*.}" = "json" ]; then
7-
./checker lint $f
6+
./checker lint "$f"
87
fi
98
done

scripts/show-files.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
set -e
2-
files="$@"
1+
set -euo pipefail
32

4-
for f in $files
3+
for f in "$@"
54
do
65
if [ "${f##*.}" = "json" ]; then
7-
./checker show-files $f
6+
./checker show-files "$f"
87
fi
98
done

0 commit comments

Comments
 (0)