Skip to content

Commit d9d9dfe

Browse files
committed
Add shellcheck to formatting action
1 parent de15af1 commit d9d9dfe

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

.github/workflows/format.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ jobs:
5151
fi
5252
done
5353
54+
55+
- name: Format modified shell scripts
56+
env:
57+
filter: ${{ github.event.before }}
58+
run: |
59+
sudo apt-get update
60+
sudo apt-get install -y shellcheck shfmt
61+
for FILE in $(git diff --name-only $filter | grep -E '.*\.(sh)$')
62+
do
63+
# Check if the file still exists in the working tree
64+
if [ -f "$FILE" ]; then
65+
shellcheck --format=diff "$FILE" | patch -p1 "$FILE"
66+
shfmt -w "$FILE"
67+
git add $FILE
68+
fi
69+
done
70+
71+
5472
- name: Commit and push changes
5573
run: |
5674
HAS_CHANGES=$(git diff --staged --name-only)

0 commit comments

Comments
 (0)