Skip to content

Commit 1d97d84

Browse files
authored
Add workingDirectory argument (#283)
Related: #205 (comment)
1 parent a99389a commit 1d97d84

File tree

4 files changed

+39
-11
lines changed

4 files changed

+39
-11
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ jobs:
6060
'./**/*.html'
6161
'./**/*.rst'
6262
63+
- name: test working directory functionality
64+
uses: ./
65+
with:
66+
workingDirectory: fixtures/subdir
67+
args: --dump-inputs '*'
68+
output: ${{ github.workspace }}/working_dir_inputs.txt
69+
70+
- name: test working directory output
71+
run: |
72+
line_count=$(wc -l < ${{ github.workspace }}/working_dir_inputs.txt)
73+
if ! grep -q "test-working-dir.md" ${{ github.workspace }}/working_dir_inputs.txt || [ "$line_count" -ne 2 ]; then
74+
echo "Working directory test failed. Output:"
75+
cat ${{ github.workspace }}/working_dir_inputs.txt
76+
exit 1
77+
fi
78+
6379
- name: test custom output relative path - creation
6480
uses: ./
6581
with:

README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,18 @@ lychee arguments can be passed to the action via the `args` parameter.
5454

5555
On top of that, the action also supports some additional arguments.
5656

57-
| Argument | Examples | Description |
58-
| ------------- | ----------------------- | ------------------------------------------------------------------------------- |
59-
| args | `--cache`, `--insecure` | See [lychee's documentation][lychee-args] for all arguments and values |
60-
| debug | `false` | Enable debug output in action (set -x). Helpful for troubleshooting |
61-
| fail | `false` | Fail workflow run on error (i.e. when [lychee exit code][lychee-exit] is not 0) |
62-
| failIfEmpty | `false` | Fail entire pipeline if no links were found |
63-
| format | `markdown`, `json` | Summary output format |
64-
| jobSummary | `false` | Write GitHub job summary (on Markdown output only) |
65-
| lycheeVersion | `v0.15.0`, `nightly` | Overwrite the lychee version to be used |
66-
| output | `lychee/results.md` | Summary output file path |
67-
| token | `""` | Custom GitHub token to use for API calls |
57+
| Argument | Examples | Description |
58+
| ---------------- | ----------------------- | --------------------------------------------------------------------------------------- |
59+
| args | `--cache`, `--insecure` | See [lychee's documentation][lychee-args] for all arguments and values |
60+
| debug | `false` | Enable debug output in action (set -x). Helpful for troubleshooting |
61+
| fail | `false` | Fail workflow run on error (i.e. when [lychee exit code][lychee-exit] is not 0) |
62+
| failIfEmpty | `false` | Fail entire pipeline if no links were found |
63+
| format | `markdown`, `json` | Summary output format |
64+
| jobSummary | `false` | Write GitHub job summary (on Markdown output only) |
65+
| lycheeVersion | `v0.15.0`, `nightly` | Overwrite the lychee version to be used |
66+
| output | `lychee/results.md` | Summary output file path |
67+
| token | `""` | Custom GitHub token to use for API calls |
68+
| workingDirectory | `.`, `path/to/subdir/` | Custom working directory to run lychee in. This affects where `output.md` gets created. |
6869

6970
See [action.yml](./action.yml) for a full list of supported arguments and their default values.
7071

@@ -86,6 +87,9 @@ Here is how to pass the arguments.
8687
token: ${{ secrets.CUSTOM_TOKEN }}
8788
# Don't fail action on broken links
8889
fail: false
90+
# Run lychee in a different directory.
91+
# Note: This changes the lychee output directory as well.
92+
workingDirectory: website/subdir
8993
```
9094

9195
(If you need a token that requires permissions that aren't available in the
@@ -144,6 +148,8 @@ If you need more control over when caches are restored and saved, you can split
144148
Add a `.lycheeignore` file to the root of your repository to exclude links from
145149
getting checked. It supports regular expressions. One expression per line.
146150

151+
You can also put your `.lycheeignore` into a subdirectory if you set that as the `workingDirectory`.
152+
147153
## Fancy badge
148154

149155
Pro tip: You can add a little badge to your repo to show the status of your

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ inputs:
4242
description: "Your GitHub Access Token, defaults to: {{ github.token }}"
4343
default: ${{ github.token }}
4444
required: false
45+
workingDirectory:
46+
description: "Directory to run lychee in"
47+
default: "."
48+
required: false
4549

4650
outputs:
4751
exit_code:
@@ -111,6 +115,7 @@ runs:
111115

112116
- name: Run Lychee
113117
id: run-lychee
118+
working-directory: ${{ inputs.workingDirectory }}
114119
run: ${{ github.action_path }}/entrypoint.sh
115120
env:
116121
# https://github.com/actions/runner/issues/665

fixtures/subdir/test-working-dir.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Test File with [Link](https://lychee.cli.rs/)

0 commit comments

Comments
 (0)