Skip to content

Commit

Permalink
Make entrypoint.sh more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
nosborn committed Jun 9, 2022
1 parent 94ba101 commit 9ac43c5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions entrypoint.sh
@@ -1,5 +1,10 @@
#!/bin/sh

env | sort

set -o errexit
set -o nounset

: "${INPUT_CONFIG:=${INPUT_CONFIG_FILE:-}}"
: "${INPUT_IGNORE:=${INPUT_IGNORE_FILES:-}}"

Expand All @@ -9,15 +14,16 @@ MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE:+ -i ${INPUT_IGNORE}}"
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH}}"
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_RULES:+ -r ${INPUT_RULES}}"

PROBLEM_MATCHER="$(mktemp -p "${GITHUB_WORKSPACE}")"
PROBLEM_MATCHER="$(mktemp -p "${GITHUB_WORKSPACE:?}")"
trap 'rm -f "${PROBLEM_MATCHER}"' EXIT
cp /markdownlint-problem-matcher.json "${PROBLEM_MATCHER:?}" || exit
echo "::add-matcher::${PROBLEM_MATCHER:?}"
cp /markdownlint-problem-matcher.json "${PROBLEM_MATCHER}" || exit
echo "::add-matcher::${PROBLEM_MATCHER}"

printf 'Running %s\n' "${MARKDOWNLINT}"
# shellcheck disable=SC2086
${MARKDOWNLINT} ${INPUT_FILES}
readonly RC=$?
${MARKDOWNLINT} ${INPUT_FILES:?} || readonly rc=$?

echo '::remove-matcher owner=markdownlint::'

exit ${RC}
# shellcheck disable=SC2248
exit ${rc:-}

0 comments on commit 9ac43c5

Please sign in to comment.