Skip to content

Commit 9da5450

Browse files
committed
Add actionlint to pre-commit
This allows us to stop manually linting shell scripts in our actions, as actionlint will do this better (it understands the GitHub Actions workflow syntax).
1 parent c25bcdb commit 9da5450

2 files changed

Lines changed: 5 additions & 23 deletions

File tree

.github/workflows/shell-ci.yml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,6 @@ jobs:
2222
-path "*/.terraform/*" \
2323
| xargs -L1 shellcheck
2424
25-
- name: Lint shell scripts in GitHub actions
26-
run: |
27-
# This is not the usual/best way to get the script directory.
28-
# We need to do this here because GitHub Actions writes the
29-
# content of script blocks like these to a temp directory,
30-
# which means the source code directory and the directory
31-
# in which the script reside are different
32-
script_dir="$(readlink -f "$(dirname .github)")"
33-
34-
while IFS= read -r -d '' workflow
35-
do
36-
for path in $(yq '.jobs[] | .steps[] | select(.|has("run")) | .run | "."+(path | join("."))' "${script_dir}/${workflow}");
37-
do
38-
pushd "$(mktemp -d)" >/dev/null || exit
39-
workflow_name="$(basename "${script_dir}/${workflow}")"
40-
file="${workflow_name}__${path}"
41-
touch "${file}"
42-
yq "${path}" "${script_dir}/${workflow}" > "${file}"
43-
shellcheck -s bash "${file}"
44-
popd >/dev/null || exit
45-
done
46-
done < <(find ".github/workflows" -type f \( -name "*.yml" -or -name "*.yaml" \) -print0)
47-
4825
- name: Lint shell scripts in CodeBuild build specs
4926
run: |
5027
./support/shellcheck_codebuild.sh

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,8 @@ repos:
4949
- ruby
5050
language: system
5151
entry: make lint_ruby
52+
53+
- repo: https://github.com/rhysd/actionlint
54+
rev: v1.7.7
55+
hooks:
56+
- id: actionlint

0 commit comments

Comments
 (0)