Skip to content

Commit 9191fac

Browse files
See if I can fix the autofix workflow by using our existing actions to detect changed files
1 parent 94e376c commit 9191fac

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

.github/workflows/pr-autofix.yml

+16-23
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,27 @@ jobs:
1313
- name: Setup Node.js, install deps
1414
uses: ./.github/actions/setup
1515

16-
- id: paths_src_
17-
name: 'Check paths: src/**'
18-
run: >-
19-
BASE=${GITHUB_BASE_REF:-HEAD~1}
20-
21-
if [[ -n $(git diff --name-only refs/remotes/origin/$BASE --relative |
22-
grep '^src/.*$') ]]
23-
24-
then
25-
26-
echo "changed=true" >> $GITHUB_OUTPUT
27-
28-
exit 0
29-
30-
fi
31-
32-
echo "changed=false" >> $GITHUB_OUTPUT
33-
34-
exit 0
16+
- name: Get All Changed Files
17+
uses: Khan/actions@get-changed-files-v1
18+
id: changed
19+
with:
20+
directories: src/
21+
22+
- id: changed-js
23+
name: Find .js changed files
24+
uses: Khan/actions@filter-files-v1
25+
if: always()
26+
with:
27+
changed-files: ${{ steps.changed.outputs.files }}
28+
extensions: '.js'
3529

3630
- name: Run prettier
37-
run: >-
38-
node ./node_modules/actions-utils/list-changed-files.js | grep
39-
'.*\.js$' | xargs npm run -s format-files
31+
if: steps.changed-js.outputs.filtered != ''
32+
run: yarn run format-files ${{ steps.changed-js.outputs.filtered }}
4033

4134
- name: Rebuild our "dist" file
35+
if: steps.changed.outputs.files != ''
4236
run: yarn build
43-
if: steps.paths_src_.outputs.changed == 'true'
4437

4538
- uses: Khan/autofix-commit-action@main
4639
env:

0 commit comments

Comments
 (0)