From 871733a8a9a74332341b8d13ca4a96e55aa0726c Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 25 Apr 2024 15:19:08 +0200 Subject: [PATCH] Exit in case output is set in args and action input I decided to make this a hard error, because it keeps the entrypoint simple. Fixes #201 --- .github/workflows/test.yml | 14 ++++++++++++++ entrypoint.sh | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2466d74..abede88 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -101,6 +101,20 @@ jobs: cat "${{ env.CUSTOM_OUTPUT_DUMP_PATH }}" fi + - name: test output set in args and action input + id: output_set_in_args_and_action_input + uses: ./ + with: + args: --output foo - + output: bar + continue-on-error: true + + - name: test output set in args and action input should fail - validation + if: steps.output_set_in_args_and_action_input.outcome != 'failure' + run: | + echo "Output set in args and action input should have failed." + exit 1 + - name: test failIfEmpty - no links in input should fail the pipeline id: fail_if_empty_test uses: ./ diff --git a/entrypoint.sh b/entrypoint.sh index 4210a86..deebb9c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -21,6 +21,12 @@ FORMAT="" # If `format` occurs in args, ignore the value from `INPUT_FORMAT` [[ "$ARGS" =~ "--format " ]] || FORMAT="--format ${INPUT_FORMAT}" +# If `output` occurs in args and `INPUT_OUTPUT` is set, exit with an error +if [[ "$ARGS" =~ "--output " ]] && [ -n "${INPUT_OUTPUT:-}" ]; then + echo "Error: 'output' is set in args as well as in the action configuration. Please remove one of them." + exit 1 +fi + # Execute lychee eval lychee ${FORMAT} --output ${LYCHEE_TMP} ${ARGS} exit_code=$?