Skip to content

Commit

Permalink
Split up steps in action
Browse files Browse the repository at this point in the history
This helps with making the code more debuggable/maintainable
  • Loading branch information
mre authored Oct 7, 2024
1 parent 897f08a commit 7c151a7
Showing 1 changed file with 40 additions and 14 deletions.
54 changes: 40 additions & 14 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: "Lychee Broken Link Checker"
description: "Quickly check links in Markdown, HTML, and text files"

inputs:
args:
description: "Lychee arguments (https://github.com/lycheeverse/lychee#commandline-parameters)"
Expand Down Expand Up @@ -37,32 +38,56 @@ inputs:
description: "Your GitHub Access Token, defaults to: {{ github.token }}"
default: ${{ github.token }}
required: false

outputs:
exit_code:
description: "The exit code returned from Lychee"
value: ${{ steps.lychee.outputs.exit_code }}
value: ${{ steps.run-lychee.outputs.exit_code }}

runs:
using: "composite"
steps:
- name: Install lychee
- name: Set up environment
run: |
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
mkdir -p "$HOME/.local/bin"
shell: bash

- name: Determine Lychee filename
id: lychee-filename
run: |
if [[ '${{ inputs.lycheeVersion }}' =~ ^v0\.0|^v0\.1[0-5]\. ]]; then
echo "filename=lychee-${{ inputs.lycheeVersion }}-x86_64-unknown-linux-gnu.tar.gz" >> $GITHUB_OUTPUT
else
echo "filename=lychee-x86_64-unknown-linux-gnu.tar.gz" >> $GITHUB_OUTPUT
fi
shell: bash

- name: Download Lychee
run: |
curl -sfLO "https://github.com/lycheeverse/lychee/releases/download/${{ inputs.lycheeVersion }}/${{ steps.lychee-filename.outputs.filename }}"
shell: bash

- name: Extract Lychee
run: |
tar -xvzf "${{ steps.lychee-filename.outputs.filename }}"
shell: bash

- name: Install Lychee
run: |
# Cleanup artifacts from previous run in case it crashed
rm -rf "lychee-${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz" lychee
case '${{ inputs.LYCHEEVERSION }}' in
v0.0*|v0.1[0-5].*) filename='lychee-${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz';;
*) filename='lychee-x86_64-unknown-linux-gnu.tar.gz'
esac
curl -sfLO "https://github.com/lycheeverse/lychee/releases/download/${{ inputs.LYCHEEVERSION }}/$filename"
tar -xvzf "$filename"
rm "$filename"
install -t "$HOME/.local/bin" -D lychee
shell: bash

- name: Clean up installation files
run: |
rm -f "${{ steps.lychee-filename.outputs.filename }}"
shopt -s extglob
rm -f lychee*!(lychee-bin|lychee-lib)
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
shell: bash
- name: Run lychee
run: ${{ github.action_path }}/entrypoint.sh

- name: Run Lychee
id: lychee
run: ${{ github.action_path }}/entrypoint.sh
env:
# https://github.com/actions/runner/issues/665
INPUT_TOKEN: ${{ inputs.TOKEN }}
Expand All @@ -74,6 +99,7 @@ runs:
INPUT_JOBSUMMARY: ${{ inputs.JOBSUMMARY }}
INPUT_OUTPUT: ${{ inputs.OUTPUT }}
shell: bash

branding:
icon: "external-link"
color: "purple"

0 comments on commit 7c151a7

Please sign in to comment.