Skip to content

Commit 0989b77

Browse files
authored
fix(github-actions): changed files output for editorcondig-checker (#1180)
* 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. * feat(ci): print changed files to log in lint job
1 parent 6520331 commit 0989b77

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,34 @@ 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+
CHANGED_FILES=$(git diff --name-only "${BASE_SHA:-$BEFORE_SHA}...${HEAD_SHA:-GITHUB_REF}")
19+
echo "::notice::Changed files: $CHANGED_FILES"
20+
{
21+
echo "added_modified<<EOF"
22+
echo "$CHANGED_FILES"
23+
echo "EOF"
24+
} >> "$GITHUB_OUTPUT"
25+
env:
26+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
27+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
28+
BEFORE_SHA: "${{ github.event.before }}"
2029
- uses: 'actions/setup-go@v5'
2130
with:
2231
go-version: '1.20'
32+
- name: 'Install EditorConfig Lint'
33+
run: go install 'github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@latest'
2334
- 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[@]}
35+
run: echo "$FILES" | xargs ~/go/bin/editorconfig-checker
36+
env:
37+
# NOTE: use env to pass the output in order to avoid possible injection attacks
38+
FILES: "${{ steps.files.outputs.added_modified }}"
3039

3140
typo:
3241
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)