diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 444d08d..f890573 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -60,6 +60,22 @@ jobs: './**/*.html' './**/*.rst' + - name: test working directory functionality + uses: ./ + with: + workingDirectory: fixtures/subdir + args: --dump-inputs '*' + output: ${{ github.workspace }}/working_dir_inputs.txt + + - name: test working directory output + run: | + line_count=$(wc -l < ${{ github.workspace }}/working_dir_inputs.txt) + if ! grep -q "test-working-dir.md" ${{ github.workspace }}/working_dir_inputs.txt || [ "$line_count" -ne 2 ]; then + echo "Working directory test failed. Output:" + cat ${{ github.workspace }}/working_dir_inputs.txt + exit 1 + fi + - name: test custom output relative path - creation uses: ./ with: diff --git a/README.md b/README.md index fd4bff9..d5b0d06 100644 --- a/README.md +++ b/README.md @@ -54,17 +54,18 @@ lychee arguments can be passed to the action via the `args` parameter. On top of that, the action also supports some additional arguments. -| Argument | Examples | Description | -| ------------- | ----------------------- | ------------------------------------------------------------------------------- | -| args | `--cache`, `--insecure` | See [lychee's documentation][lychee-args] for all arguments and values | -| debug | `false` | Enable debug output in action (set -x). Helpful for troubleshooting | -| fail | `false` | Fail workflow run on error (i.e. when [lychee exit code][lychee-exit] is not 0) | -| failIfEmpty | `false` | Fail entire pipeline if no links were found | -| format | `markdown`, `json` | Summary output format | -| jobSummary | `false` | Write GitHub job summary (on Markdown output only) | -| lycheeVersion | `v0.15.0`, `nightly` | Overwrite the lychee version to be used | -| output | `lychee/results.md` | Summary output file path | -| token | `""` | Custom GitHub token to use for API calls | +| Argument | Examples | Description | +| ---------------- | ----------------------- | --------------------------------------------------------------------------------------- | +| args | `--cache`, `--insecure` | See [lychee's documentation][lychee-args] for all arguments and values | +| debug | `false` | Enable debug output in action (set -x). Helpful for troubleshooting | +| fail | `false` | Fail workflow run on error (i.e. when [lychee exit code][lychee-exit] is not 0) | +| failIfEmpty | `false` | Fail entire pipeline if no links were found | +| format | `markdown`, `json` | Summary output format | +| jobSummary | `false` | Write GitHub job summary (on Markdown output only) | +| lycheeVersion | `v0.15.0`, `nightly` | Overwrite the lychee version to be used | +| output | `lychee/results.md` | Summary output file path | +| token | `""` | Custom GitHub token to use for API calls | +| workingDirectory | `.`, `path/to/subdir/` | Custom working directory to run lychee in. This affects where `output.md` gets created. | See [action.yml](./action.yml) for a full list of supported arguments and their default values. @@ -86,6 +87,9 @@ Here is how to pass the arguments. token: ${{ secrets.CUSTOM_TOKEN }} # Don't fail action on broken links fail: false + # Run lychee in a different directory. + # Note: This changes the lychee output directory as well. + workingDirectory: website/subdir ``` (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 Add a `.lycheeignore` file to the root of your repository to exclude links from getting checked. It supports regular expressions. One expression per line. +You can also put your `.lycheeignore` into a subdirectory if you set that as the `workingDirectory`. + ## Fancy badge Pro tip: You can add a little badge to your repo to show the status of your diff --git a/action.yml b/action.yml index 90a7bb4..b706f73 100644 --- a/action.yml +++ b/action.yml @@ -42,6 +42,10 @@ inputs: 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: @@ -111,6 +115,7 @@ runs: - name: Run Lychee id: run-lychee + working-directory: ${{ inputs.workingDirectory }} run: ${{ github.action_path }}/entrypoint.sh env: # https://github.com/actions/runner/issues/665 diff --git a/fixtures/subdir/test-working-dir.md b/fixtures/subdir/test-working-dir.md new file mode 100644 index 0000000..9020297 --- /dev/null +++ b/fixtures/subdir/test-working-dir.md @@ -0,0 +1 @@ +# Test File with [Link](https://lychee.cli.rs/)