Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
133 lines (128 loc) · 5.04 KB
/
Copy pathaction.yml
File metadata and controls
133 lines (128 loc) · 5.04 KB
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
124
125
126
127
128
129
130
131
132
133
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.24.2
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 }}
required: false
workingDirectory:
description: "Directory to run lychee in"
default: "."
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: |
# Install into $RUNNER_TEMP (not $HOME) so the install path is stable
# across composite steps. On some runners $HOME is overridden per step
# (e.g. actions/checkout temporarily sets it), which made the PATH
# entry from one step and the install in another step diverge.
echo "$RUNNER_TEMP/lychee/bin" >> "$GITHUB_PATH"
mkdir -p "$RUNNER_TEMP/lychee/bin"
shell: bash
- name: Download and extract lychee in temp directory
id: lychee-setup
run: |
# Create a temporary directory for downloads and extraction
TEMP_DIR="${RUNNER_TEMP}/lychee-download"
rm -rf "${TEMP_DIR}" && mkdir -p "${TEMP_DIR}"
cd "${TEMP_DIR}"
ARCH=$(uname -m)
# Determine filename and download URL based on version
if [[ "${LYCHEE_VERSION}" =~ ^v0\.0|^v0\.1[0-5]\. ]]; then
FILENAME="lychee-${LYCHEE_VERSION}-${ARCH}-unknown-linux-gnu.tar.gz"
DOWNLOAD_URL="https://github.com/lycheeverse/lychee/releases/download/${LYCHEE_VERSION}/${FILENAME}"
else
FILENAME="lychee-${ARCH}-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}"
rm -rv "${FILENAME}"
# Detect if lychee binary is in a subfolder within the tar.gz
if ! [[ -f "${TEMP_DIR}/lychee" ]]; then
TEMP_DIR="$(echo "${TEMP_DIR}"/lychee-*)" # need `echo` to evaluate glob
fi
if ! [[ -f "${TEMP_DIR}/lychee" ]]; then
echo "Cannot find lychee binary in $TEMP_DIR. Did the archive structure change?" >&2
exit 1
fi
# Output temp directory for use in later steps
echo "temp_dir=${TEMP_DIR}" >> $GITHUB_OUTPUT
env:
LYCHEE_VERSION: ${{ inputs.lycheeVersion }}
shell: bash
- name: Install lychee
run: |
# Install lychee from the temporary directory
install -t "$RUNNER_TEMP/lychee/bin" -D "${{ steps.lychee-setup.outputs.temp_dir }}/lychee"
shell: bash
- name: Run Lychee
id: run-lychee
working-directory: ${{ inputs.workingDirectory }}
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_CHECKBOX: ${{ inputs.CHECKBOX }}
INPUT_OUTPUT: ${{ inputs.OUTPUT }}
SUMMARY_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#summary-${{ job.check_run_id }}
shell: bash
branding:
icon: "external-link"
color: "purple"