Skip to content

Commit

Permalink
build: squash: let's try an action instead of a workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmccormick committed Mar 2, 2023
1 parent 3e0dce4 commit 6c3f604
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/actions/shellcheck/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This is a reusable action for running ShellCheck,
# a linter for shell scripts (https://shellcheck.net).

# For more context, see:
# https://github.com/openedx/.github/blob/master/docs/decisions/0001-shellcheck.rst

name: ShellCheck

inputs:

root-dirs:
description: "Directories to search for .sh files, space-separated."
reqired: true

# We pin a reasonable default version here and will update it over time.
# However, repositories that are particuarly concerned about
# build stability should specify an override shellcheck-version
# and manage updates themselves.
shellcheck-version:
description: "ShellCheck version to install.Must be a tag or branch of https://github.com/koalaman/shellcheck."
required: false
default: "v0.9.0"

shellcheck-options:
description: "Command-line options to pass through to shellcheck."
required: false
default: ""

runs:

using: composite

# Note: Unfortunately, GitHub will not print the names of steps in
# composite actions, so we must rely on comments and echo'ing to
# make it clear to the user what's going on on.
steps:

- shell: bash
run: |
# Download, unpack & install ShellCheck ${{ inputs.shellcheck-version }}.
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${{ inputs.shellcheck-version }}/shellcheck-${{ inputs.shellcheck-version}}.linux.x86_64.tar.xz" | tar -xJ
sudo cp "shellcheck-${{ inputs.shellcheck-version }}/shellcheck" /usr/bin
echo "Successfully installed:"
shellcheck -V
echo
- shell: bash
run: |
# Ensure that at least one shell script will be checked
if [[ -z "$(find ${{ inputs.root-dirs }} -name '*.sh')" ]] ; then
echo "Error: No matching shell scripts found!"
exit 3
fi
echo "The following shell scripts will be checked:"
find ${{ inputs.root-dirs }} -name '*.sh'
echo
# This step is intentionally a big one-line command so that
# devs can easily copy it and run it on their own machine.
- shell: bash
run: find ${{ inputs.root-dirs }} -name '*.sh' -print0 | xargs -0 shellcheck ${{ inputs.shellcheck-options }}

0 comments on commit 6c3f604

Please sign in to comment.