Closed tooomm closed 9 months ago
Yeah, that's a bug in lychee then. It should consider the output setting. Let me move that over to the main repo.
Actually I'm confused. It should work:
This has always been the case, ever since we supported dumping links in the first place. https://github.com/lycheeverse/lychee/commit/35ccfb87c3c6bd53efb6340fe92c80296c8c0757
Hmm, did you make it work with you GH Action? As I noted, I might just don't know where the file ends up and how to properly call it from the action.
If you've an example at hand that would be awesome!
Whoops, then let me move it back to lychee-action. Apologies for the confusion. You can decide where the file ends up in the action.
- name: Link Checker
uses: lycheeverse/lychee-action@master
with:
# Check all markdown and html files in repo (default)
args: --base . --dump './**/*.md' './**/*.html' './**/*.rst'
# Use different output file path
output: /tmp/foo.txt
The default path currently is lychee/out.md
(as defined in the action.yml).
If the output does not end up there, that's a bug.
To reuse the output in a downstream job that depends on this job, see "Defining outputs for jobs" in the GitHub Docs.
Thanks again for trying to help here, mre!
You can decide where the file ends up in the action.
That's correct.
As stated in the issue description, I was using output
and was not able to spot the file when trying various possibilities.
Same actually, when using the default location and not using a custom path for output.
So the question is still the same... :D Can not tell if it's a bug or me being the issue here.
To reuse the output in a downstream job that depends on this job, see "Defining outputs for jobs" in the GitHub Docs.
It should only be used in a subsequent step within the same job.
Can you provide me a working example that e.g. prints the file afterwards in a following step in the action?
Taking your above example here, how to print the foo.txt
file for example... I could not find/link the file in my tests.
jobs:
test-job:
runs-on: ubuntu-latest
steps:
- name: Dump Output
uses: lycheeverse/lychee-action@v1
with:
# Check all markdown and html files in repo (default)
args: --base . --dump './**/*.md' './**/*.html' './**/*.rst'
# Use different output file path
output: /tmp/foo.txt
- name: Print Output
shell: bash
run: cat ???
Hum, I don't know the answer. This doesn't work at least:
name: Links
on:
workflow_dispatch:
jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Dump Output
uses: lycheeverse/lychee-action@v1.8.0
with:
args: --dump './**/*.md' './**/*.html' './**/*.rst'
output: ./lychee/out.md
debug: true
- name: Print Output
run: cat ./lychee/out.md
Output:
Run cat ./lychee/out.md
cat: ./lychee/out.md: No such file or directory
Error: Process completed with exit code 1.
I've added the debug flag. Maybe that helps to troubleshoot the issue.
So I'm running into a similar situation, where when I pass in the output
command, it fails: https://github.com/LilDrunkenSmurf/k3s-home-cluster/actions/runs/7309944973/job/19918081978#step:4:110
I setup debug, and tried to print the output, and I noticed it's not evaluating the second if
statement here: https://github.com/lycheeverse/lychee-action/blob/ef8c8f32c278e9eed290c6e6c96748f16b6cd335/entrypoint.sh#L33
It looks like it runs the if
statement above, , and evaluates it to false, and carries on, but skips the next one.
Rather than making it two different if statements, perhaps it should be nested.
Something like:
# Ensure we have any output
if [ ! -f "${LYCHEE_TMP}" ]; then
echo "No output. Check pipeline run to see if lychee panicked." > "${LYCHEE_TMP}"
else if
# If we have any output, create a report in the designated directory
mkdir -p "$(dirname -- "${INPUT_OUTPUT}")"
cat "${LYCHEE_TMP}" > "${INPUT_OUTPUT}"
if [ "${INPUT_FORMAT}" == "markdown" ]; then
echo "[Full Github Actions output](${GITHUB_WORKFLOW_URL})" >> "${INPUT_OUTPUT}"
fi
fi
Cool. Can you send a pull request with that change, so we can test it?
Tested the PR, and it looks good.
@LilDrunkenSmurf fixed it in #215. Thanks! We've also added an integration test in #217 to make sure it doesn't break in the future. @tooomm fyi.
Also added an integration test for --dump
specifically. https://github.com/lycheeverse/lychee-action/pull/218
It looks like
--dump
only prints the found links to the console.I would like to dump the extracted links to a file to further work with it. Not sure how to do this with the action.
output:
is not considered, or I'm not sure of the actual location 🤔