Skip to content

Commit 9d36a8f

Browse files
committed
fix(github-actions): changed files output for editorcondig-checker
Seems that ci.yml includes a dead dependency action just to get list of changed files for the PR / push. This seems weird as the repo is all about git. Propose removing this extra dep with straightforward implemenation. Also: github runners do have `jq` preinstalled.
1 parent fb0bc69 commit 9d36a8f

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,32 @@ jobs:
88
lint:
99
runs-on: 'ubuntu-latest'
1010
steps:
11-
- name: 'Get Changed Files'
12-
id: 'files'
13-
uses: 'masesgroup/retrieve-changed-files@v3'
14-
with:
15-
format: 'json'
16-
# a force push will cause the action above to fail. Don't do force push when people are
17-
# reviewing!
1811
- name: Check out code.
1912
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
- name: 'Get Changed Files'
16+
id: 'files'
17+
run: |
18+
{
19+
echo "added_modified<<EOF"
20+
git diff --name-only "${BASE_SHA:-$BEFORE_SHA}...${HEAD_SHA:-GITHUB_REF}"
21+
echo "EOF"
22+
} >> "$GITHUB_OUTPUT"
23+
env:
24+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
25+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
26+
BEFORE_SHA: "${{ github.event.before }}"
2027
- uses: 'actions/setup-go@v5'
2128
with:
2229
go-version: '1.20'
30+
- name: 'Install EditorConfig Lint'
31+
run: go install 'github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@latest'
2332
- name: 'Check EditorConfig Lint'
24-
run: |
25-
sudo apt install -y jq
26-
go install 'github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@latest'
27-
28-
readarray -t changed_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.added_modified }}')"
29-
~/go/bin/editorconfig-checker ${changed_files[@]}
33+
run: echo "$FILES" | xargs ~/go/bin/editorconfig-checker
34+
env:
35+
# NOTE: use env to pass the output in order to avoid possible injection attacks
36+
FILES: "${{ steps.files.outputs.added_modified }}"
3037

3138
typo:
3239
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)