mirror of
https://github.com/ludeeus/action-shellcheck.git
synced 2025-09-16 13:16:28 +02:00
Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
513f424cc7 | ||
![]() |
fbd26dc426 | ||
![]() |
f22efe748c | ||
![]() |
b44aa9b87a | ||
![]() |
acc4e4fe97 | ||
![]() |
6eb62923bc | ||
![]() |
3a4806a465 | ||
![]() |
21696cbf1a | ||
![]() |
fa3cc6ede4 | ||
![]() |
18c29dd450 | ||
![]() |
c07d062aa5 | ||
![]() |
a1eeadd7ec | ||
![]() |
f615dc5486 | ||
![]() |
b443c466bf | ||
![]() |
35efb355bc | ||
![]() |
5e7f90b47a | ||
![]() |
70c0c19934 | ||
![]() |
9f3543661d | ||
![]() |
746dd2ddc0 | ||
![]() |
88a963fbeb | ||
![]() |
2e9d4c556d | ||
![]() |
9445381284 | ||
![]() |
370adf4cb6 | ||
![]() |
43d591f972 |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* text=auto eol=lf
|
16
.github/main.workflow
vendored
16
.github/main.workflow
vendored
@@ -1,16 +0,0 @@
|
||||
workflow "Trigger: Push" {
|
||||
on = "push"
|
||||
resolves = [
|
||||
"Shellcheck",
|
||||
"Black Code Formatter",
|
||||
]
|
||||
}
|
||||
|
||||
action "Shellcheck" {
|
||||
uses = "ludeeus/action-shellcheck@master"
|
||||
}
|
||||
|
||||
action "Black Code Formatter" {
|
||||
uses = "lgeiger/black-action@master"
|
||||
args = "$GITHUB_WORKSPACE --check"
|
||||
}
|
13
.github/workflows/push.yml
vendored
Normal file
13
.github/workflows/push.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
on: push
|
||||
name: 'Trigger: Push'
|
||||
jobs:
|
||||
shellcheck:
|
||||
name: ShellCheck
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
- name: Run ShellCheck
|
||||
uses: ./
|
||||
with:
|
||||
ignore: ignore
|
18
Dockerfile
18
Dockerfile
@@ -1,16 +1,6 @@
|
||||
FROM debian:latest
|
||||
FROM alpine:3.11.6
|
||||
|
||||
COPY runaction.sh /runaction.sh
|
||||
RUN chmod +x /runaction.sh
|
||||
RUN apt update
|
||||
RUN apt install -y shellcheck
|
||||
RUN apk add --no-cache shellcheck bash
|
||||
|
||||
ENTRYPOINT ["/runaction.sh"]
|
||||
|
||||
LABEL "name"="shellcheck"
|
||||
LABEL "maintainer"="Ludeeus <ludeeus@gmail.com>"
|
||||
LABEL "version"="0.0.1"
|
||||
LABEL "com.github.actions.name"="shellcheck"
|
||||
LABEL "com.github.actions.description"="Run shell check on ALL sh files in the repository."
|
||||
LABEL "com.github.actions.icon"="terminal"
|
||||
LABEL "com.github.actions.color"="black"
|
||||
COPY runaction.sh /action/runaction.sh
|
||||
ENTRYPOINT ["bash", "/action/runaction.sh"]
|
67
README.md
67
README.md
@@ -1,24 +1,59 @@
|
||||
# SHELLCHECK
|
||||
# ShellCheck
|
||||
|
||||
[![BuyMeCoffee][buymecoffeebedge]][buymecoffee]
|
||||
|
||||
_Run shellcheck on ALL sh files in the repository._
|
||||
_GitHub action for ShellCheck._
|
||||
|
||||
## Example
|
||||
|
||||
```
|
||||
workflow "Shellcheck" {
|
||||
on = "push"
|
||||
resolves = [
|
||||
"Shellcheck",
|
||||
]
|
||||
}
|
||||
```yaml
|
||||
on:
|
||||
push:
|
||||
branch:
|
||||
- master
|
||||
|
||||
name: 'Trigger: Push action'
|
||||
|
||||
action "Shellcheck" {
|
||||
uses = "ludeeus/actions/shellcheck@master"
|
||||
}
|
||||
jobs:
|
||||
shellcheck:
|
||||
name: Shellcheck
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Run ShellCheck
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
```
|
||||
|
||||
[buymecoffee]: https://www.buymeacoffee.com/ludeeus
|
||||
[buymecoffeebedge]: https://camo.githubusercontent.com/cd005dca0ef55d7725912ec03a936d3a7c8de5b5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275792532306d6525323061253230636f666665652d646f6e6174652d79656c6c6f772e737667
|
||||
## Globally disable checks
|
||||
|
||||
To disable specific checks add it to a `SHELLCHECK_OPTS` env key in the job definition.
|
||||
|
||||
example:
|
||||
|
||||
```yaml
|
||||
...
|
||||
- name: Run ShellCheck
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
env:
|
||||
SHELLCHECK_OPTS: -e SC2059 -e SC2034 -e SC1090
|
||||
```
|
||||
|
||||
## Ignore paths
|
||||
|
||||
You can use the `ignore` input to disable specific directories.
|
||||
|
||||
```text
|
||||
sample structure:
|
||||
sample/directory/with/files/toignore/test.sh
|
||||
sample/directory/with/files/test.sh
|
||||
```
|
||||
|
||||
example:
|
||||
|
||||
```yaml
|
||||
...
|
||||
- name: Run ShellCheck
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
with:
|
||||
ignore: toignore
|
||||
```
|
||||
|
||||
This will skip `sample/directory/with/files/toignore/test.sh`
|
||||
|
14
action.yaml
Normal file
14
action.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
name: "ShellCheck"
|
||||
author: "Ludeeus <hi@ludeeus.dev>"
|
||||
description: "GitHub action for ShellCheck."
|
||||
inputs:
|
||||
ignore:
|
||||
description: 'Paths to ignore when running ShellCheck'
|
||||
required: false
|
||||
default: ''
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
branding:
|
||||
icon: 'terminal'
|
||||
color: 'gray-dark'
|
72
runaction.sh
Normal file → Executable file
72
runaction.sh
Normal file → Executable file
@@ -1,4 +1,74 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd "$GITHUB_WORKSPACE" || exit 1
|
||||
find . -name \*.sh -exec shellcheck {} +
|
||||
|
||||
declare statuscode
|
||||
declare -a filepaths
|
||||
declare -a excludes
|
||||
declare -a tmp
|
||||
|
||||
statuscode=0
|
||||
|
||||
excludes+=( ! -path *./.git/* )
|
||||
excludes+=( ! -path *.go )
|
||||
excludes+=( ! -path */mvnw )
|
||||
|
||||
for path in ${INPUT_IGNORE}; do
|
||||
echo "::debug:: Adding '${path}' to excludes"
|
||||
excludes+=(! -path "*./${path}/*" )
|
||||
excludes+=(! -path "*/${path}/*" )
|
||||
done
|
||||
|
||||
readarray -d '' filepaths < <(find . "${excludes[@]}" \
|
||||
'(' \
|
||||
\
|
||||
-name '*.bash' \
|
||||
-o -path '*/.bash*' \
|
||||
-o -path '*/bash*' \
|
||||
-o -name '*.ksh' \
|
||||
-o -name 'ksh*' \
|
||||
-o -path '*/.ksh*' \
|
||||
-o -path '*/ksh*' \
|
||||
-o -name 'suid_profile' \
|
||||
-o -name '*.zsh' \
|
||||
-o -name '.zlogin*' \
|
||||
-o -name 'zlogin*' \
|
||||
-o -name '.zlogout*' \
|
||||
-o -name 'zlogout*' \
|
||||
-o -name '.zprofile*' \
|
||||
-o -name 'zprofile*' \
|
||||
-o -path '*/.zsh*' \
|
||||
-o -path '*/zsh*' \
|
||||
-o -name '*.sh' \
|
||||
-o -path '*/.profile*' \
|
||||
-o -path '*/.shlib*' \
|
||||
-o -path '*/shlib*' \
|
||||
')'\
|
||||
\
|
||||
-print0)
|
||||
|
||||
|
||||
readarray -d '' tmp < <(find . "${excludes[@]}" -type f ! -name '*.*' -perm /111 -print0)
|
||||
for file in "${tmp[@]}"; do
|
||||
head -n1 "$file" | grep -Eqs "^#! */[^ ]*/[abkz]*sh" || continue
|
||||
filepaths+=("$file")
|
||||
done
|
||||
|
||||
if find . "${excludes[@]}" -path '*bin/*/*' -type f -perm /111 -print |
|
||||
grep .
|
||||
then
|
||||
echo >&2 "::warning:: subdirectories of bin directories are not usable via PATH"
|
||||
fi
|
||||
|
||||
if find . "${excludes[@]}" -path '*bin/*' -name '*.*' -type f -perm /111 -perm /444 -print |
|
||||
grep .
|
||||
then
|
||||
echo >&2 "::warning:: programs in PATH should not have a filename suffix"
|
||||
fi
|
||||
|
||||
for file in "${filepaths[@]}"; do
|
||||
echo "::debug:: Checking $file"
|
||||
shellcheck "$file" || statuscode=$?
|
||||
done
|
||||
|
||||
exit "$statuscode"
|
||||
|
3
testfiles/ignore/ignore.sh
Normal file
3
testfiles/ignore/ignore.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo $test
|
4
testfiles/test
Normal file
4
testfiles/test
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
test="test"
|
||||
echo "$test"
|
3
testfiles/test.bash
Normal file
3
testfiles/test.bash
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
test="test"
|
||||
echo "$test"
|
4
testfiles/test.sh
Normal file
4
testfiles/test.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/sh
|
||||
|
||||
test="test"
|
||||
echo "$test"
|
Reference in New Issue
Block a user