Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update To latest Release and add Checkbox Option (fixes #274) #279

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- name: test explicit lychee version
uses: ./
with:
checkbox: false # not supported in v0.15.1
lycheeVersion: v0.15.1

- name: test nightly lychee version
Expand Down Expand Up @@ -286,6 +287,7 @@ jobs:
- name: test explicit lychee version
uses: ./
with:
checkbox: false # not supported in v0.15.1
lycheeVersion: v0.15.1

- name: test nightly lychee version
Expand Down
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ inputs:
required: false
lycheeVersion:
description: "Use custom version of lychee link checker"
default: v0.18.0
default: v0.18.1
required: false
output:
description: "Summary output file path"
default: "lychee/out.md"
required: false
checkbox:
description: "Add Markdown Styled Checkboxes to the output"
default: true
required: false
token:
description: "Your GitHub Access Token, defaults to: {{ github.token }}"
default: ${{ github.token }}
Expand Down Expand Up @@ -117,6 +121,7 @@ runs:
INPUT_FAILIFEMPTY: ${{ inputs.FAILIFEMPTY }}
INPUT_FORMAT: ${{ inputs.FORMAT }}
INPUT_JOBSUMMARY: ${{ inputs.JOBSUMMARY }}
INPUT_CHECKBOX: ${{ inputs.CHECKBOX }}
INPUT_OUTPUT: ${{ inputs.OUTPUT }}
shell: bash
branding:
Expand Down
20 changes: 19 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,32 @@ 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

# If `--mode` occurs in args and `INPUT_CHECKBOX` is set, exit with an error
# Use `--mode` instead of `--mode task` to ensure that the checkbox is not getting overwritten
if [[ "$ARGS" =~ "--mode" ]] && [ -n "${INPUT_CHECKBOX:-}" ]; then
echo "Error: '--mode' is set in args but 'checkbox' is set in the action configuration. Please remove one of them to avoid conflicts."
exit 1
fi

CHECKBOX=""
if [ "${INPUT_CHECKBOX}" = true ]; then
# Check if the version is higher than 0.18.1
if [ "$(lychee --version | head -n1 | cut -d" " -f4)" -lt 0.18.1 ]; then
echo "WARNING: 'checkbox' is not supported in lychee versions lower than 0.18.1. Continuing without 'checkbox'."
else
CHECKBOX="--mode task"
fi
fi

# Execute lychee
eval lychee ${FORMAT} --output ${LYCHEE_TMP} ${ARGS}
eval lychee ${CHECKBOX} ${FORMAT} --output ${LYCHEE_TMP} ${ARGS}
LYCHEE_EXIT_CODE=$?

# If no links were found and `failIfEmpty` is set to `true` (and it is by default),
Expand Down
Loading