-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
action.yml
123 lines (112 loc) · 4.08 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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)"
default: "--verbose --no-progress './**/*.md' './**/*.html' './**/*.rst'"
required: false
debug:
description: "Enable debug output in action (set -x). Helpful for troubleshooting."
default: false
required: false
fail:
description: "Fail entire pipeline on error (i.e. when lychee exit code is not 0)"
default: true
required: false
failIfEmpty:
description: "Fail entire pipeline if no links were found"
default: true
required: false
format:
description: "Summary output format (e.g. json)"
default: "markdown"
required: false
jobSummary:
description: "Write GitHub job summary at the end of the job (written on Markdown output only)"
default: true
required: false
lycheeVersion:
description: "Use custom version of lychee link checker"
default: v0.17.0
required: false
output:
description: "Summary output file path"
default: "lychee/out.md"
required: false
token:
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.run-lychee.outputs.exit_code }}
runs:
using: "composite"
steps:
- name: Set up environment
run: |
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
mkdir -p "$HOME/.local/bin"
shell: bash
- name: Clean up existing lychee files
run: |
# Remove any existing lychee binaries or archives to prevent conflicts
rm -f "$HOME/.local/bin/lychee"
rm -rf lychee
rm -f "${{ steps.lychee-filename.outputs.filename }}"
shell: bash
- name: Download and extract lychee
id: lychee-setup
run: |
# Determine filename and download URL based on version
if [[ "${LYCHEE_VERSION}" =~ ^v0\.0|^v0\.1[0-5]\. ]]; then
FILENAME="lychee-${LYCHEE_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/download/${LYCHEE_VERSION}/${FILENAME}"
else
FILENAME="lychee-x86_64-unknown-linux-gnu.tar.gz"
if [[ "${LYCHEE_VERSION}" == 'nightly' ]]; then
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/download/nightly/${FILENAME}"
elif [[ "${LYCHEE_VERSION}" == 'latest' ]]; then
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/latest/download/${FILENAME}"
else
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/download/lychee-${LYCHEE_VERSION}/${FILENAME}"
fi
fi
echo "Downloading from: ${DOWNLOAD_URL}"
curl -sfLO "${DOWNLOAD_URL}"
echo "Extracting ${FILENAME}"
tar -xvzf "${FILENAME}"
# Output filename for use in later steps
echo "filename=${FILENAME}" >> $GITHUB_OUTPUT
env:
LYCHEE_VERSION: ${{ inputs.lycheeVersion }}
shell: bash
- name: Install lychee
run: |
install -t "$HOME/.local/bin" -D lychee
shell: bash
- name: Clean up installation files
run: |
# Remove the downloaded archive and any unnecessary files after installation
rm -f "${{ steps.lychee-setup.outputs.filename }}"
shopt -s extglob
rm -f lychee!(*-bin|*-lib|*.toml)
shell: bash
- name: Run Lychee
id: run-lychee
run: ${{ github.action_path }}/entrypoint.sh
env:
# https://github.com/actions/runner/issues/665
INPUT_TOKEN: ${{ inputs.TOKEN }}
INPUT_ARGS: ${{ inputs.ARGS }}
INPUT_DEBUG: ${{ inputs.DEBUG }}
INPUT_FAIL: ${{ inputs.FAIL }}
INPUT_FAILIFEMPTY: ${{ inputs.FAILIFEMPTY }}
INPUT_FORMAT: ${{ inputs.FORMAT }}
INPUT_JOBSUMMARY: ${{ inputs.JOBSUMMARY }}
INPUT_OUTPUT: ${{ inputs.OUTPUT }}
shell: bash
branding:
icon: "external-link"
color: "purple"