From 7c151a7e82417d3e8e86b7ddfaecf939df2c5549 Mon Sep 17 00:00:00 2001 From: Matthias Endler Date: Mon, 7 Oct 2024 11:42:55 +0200 Subject: [PATCH] Split up steps in action This helps with making the code more debuggable/maintainable --- action.yml | 54 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/action.yml b/action.yml index 535e0e8..a3909b3 100644 --- a/action.yml +++ b/action.yml @@ -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)" @@ -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 }} @@ -74,6 +99,7 @@ runs: INPUT_JOBSUMMARY: ${{ inputs.JOBSUMMARY }} INPUT_OUTPUT: ${{ inputs.OUTPUT }} shell: bash + branding: icon: "external-link" color: "purple"