diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index be78927..ca11c31 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest if: github.actor == 'dependabot[bot]' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ahmadnassri/action-dependabot-auto-merge@v2.6.6 with: github-token: ${{ secrets.AUTOMERGE_TOKEN }} diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml index cc2de5f..506273a 100644 --- a/.github/workflows/links.yml +++ b/.github/workflows/links.yml @@ -10,7 +10,7 @@ jobs: linkChecker: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Link Checker uses: ./ # Uses an action in the root directory @@ -22,7 +22,7 @@ jobs: - name: Create Issue From File if: env.lychee_exit_code != 0 - uses: peter-evans/create-issue-from-file@v4 + uses: peter-evans/create-issue-from-file@v5 with: title: Link Checker Report content-filepath: ./lychee/out.md diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f341733..f41ca1b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,11 @@ on: - push - pull_request +env: + CUSTOM_OUTPUT_RELATIVE_PATH: lychee/custom_output.md + CUSTOM_OUTPUT_ABSOLUTE_PATH: /tmp/report.md + CUSTOM_OUTPUT_DUMP_PATH: /tmp/dump.md + jobs: lychee-action: runs-on: ubuntu-latest @@ -11,7 +16,7 @@ jobs: name: Test the lychee link checker action steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: test defaults uses: ./ @@ -35,6 +40,70 @@ jobs: './**/*.rst' fail: true + - name: test --base argument + uses: ./ + with: + args: >- + --base . + --verbose + --no-progress + './**/*.md' + './**/*.html' + './**/*.rst' + fail: true + + - name: test custom output relative path - creation + uses: ./ + with: + output: "${{ env.CUSTOM_OUTPUT_RELATIVE_PATH }}" + debug: true + + - name: test custom output relative path - validation + run: | + echo "Checking custom output file at ${{ env.CUSTOM_OUTPUT_RELATIVE_PATH }}" + if [ ! -f "${{ env.CUSTOM_OUTPUT_RELATIVE_PATH }}" ]; then + echo "Not found" + exit 1 + else + echo "Found. Contents:" + cat "${{ env.CUSTOM_OUTPUT_RELATIVE_PATH }}" + fi + + - name: test custom output absolute path - creation + uses: ./ + with: + output: "${{ env.CUSTOM_OUTPUT_ABSOLUTE_PATH }}" + debug: true + + - name: test custom output absolute path - validation + run: | + echo "Checking custom output file at ${{ env.CUSTOM_OUTPUT_ABSOLUTE_PATH }}" + if [ ! -f "${{ env.CUSTOM_OUTPUT_ABSOLUTE_PATH }}" ]; then + echo "Not found" + exit 1 + else + echo "Found. Contents:" + cat "${{ env.CUSTOM_OUTPUT_ABSOLUTE_PATH }}" + fi + + - name: test dump with custom output path - creation + uses: ./ + with: + args: --dump './**/*.md' './**/*.html' './**/*.rst' + output: "${{ env.CUSTOM_OUTPUT_DUMP_PATH }}" + debug: true + + - name: test dump with custom output path - validation + run: | + echo "Checking dump output file at ${{ env.CUSTOM_OUTPUT_DUMP_PATH }}" + if [ ! -f "${{ env.CUSTOM_OUTPUT_DUMP_PATH }}" ]; then + echo "Not found" + exit 1 + else + echo "Found. Contents:" + cat "${{ env.CUSTOM_OUTPUT_DUMP_PATH }}" + fi + - name: Install jq run: sudo apt-get install jq diff --git a/.github/workflows/test_cache.yml b/.github/workflows/test_cache.yml index 18ebd98..38f2120 100644 --- a/.github/workflows/test_cache.yml +++ b/.github/workflows/test_cache.yml @@ -11,13 +11,13 @@ jobs: name: Test cache steps: - name: Restore lychee cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: .lycheecache key: cache-lychee-${{ github.sha }} restore-keys: cache-lychee- - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Lychee URL checker uses: lycheeverse/lychee-action@v1 diff --git a/README.md b/README.md index d32e0bd..27fb533 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,11 @@ jobs: linkChecker: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Link Checker id: lychee - uses: lycheeverse/lychee-action@v1.8.0 + uses: lycheeverse/lychee-action@v1.9.0 - name: Create Issue From File if: env.lychee_exit_code != 0 @@ -65,14 +65,24 @@ jobs: linkChecker: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Link Checker - uses: lycheeverse/lychee-action@v1.8.0 + uses: lycheeverse/lychee-action@v1.9.0 with: fail: true ``` +You may want to add additional arguments to the above. In particular, if you're testing a site directly from the file system (as in the above), you'll likely want to set the argument `--base .` to ensure that **all links** (including root-relative paths) in the files are tested. You don't need to do this if you're testing a hosted site. + +```yaml + - name: Link Checker + uses: lycheeverse/lychee-action@v1.9.0 + with: + fail: true + args: --base . --verbose --no-progress './**/*.md' './**/*.html' './**/*.rst' +``` + ## Passing arguments This action uses [lychee] for link checking. @@ -99,10 +109,10 @@ Here is how to pass the arguments. ```yml - name: Link Checker - uses: lycheeverse/lychee-action@v1.8.0 + uses: lycheeverse/lychee-action@v1.9.0 with: # Check all markdown and html files in repo (default) - args: --verbose --no-progress './**/*.md' './**/*.html' './**/*.rst' + args: --base . --verbose --no-progress './**/*.md' './**/*.html' './**/*.rst' # Use json as output format (instead of markdown) format: json # Use different output file path @@ -131,9 +141,9 @@ In order to mitigate issues regarding rate limiting or to reduce stress on exter restore-keys: cache-lychee- - name: Run lychee - uses: lycheeverse/lychee-action@v1.8.0 + uses: lycheeverse/lychee-action@v1.9.0 with: - args: "--cache --max-cache-age 1d ." + args: "--base . --cache --max-cache-age 1d ." ``` It will compare and save the cache based on the given key. @@ -151,9 +161,9 @@ If you need more control over when caches are restored and saved, you can split restore-keys: cache-lychee- - name: Run lychee - uses: lycheeverse/lychee-action@v1.8.0 + uses: lycheeverse/lychee-action@v1.9.0 with: - args: "--cache --max-cache-age 1d ." + args: "--base . --cache --max-cache-age 1d ." - name: Save lychee cache uses: actions/cache/save@v3 @@ -224,7 +234,7 @@ For example: ```yml - name: Link Checker - uses: lycheeverse/lychee-action@ec7614d7605b47efb08dc370f6d0a71884cba944 # for v1.8.0 + uses: lycheeverse/lychee-action@22134d37a1fff6c2974df9c92a7c7e1e86a08f9c # for v1.9.0 ``` ## Credits diff --git a/action.yml b/action.yml index 3208568..067ef7a 100644 --- a/action.yml +++ b/action.yml @@ -23,7 +23,7 @@ inputs: required: false lycheeVersion: description: "Use custom version of lychee link checker" - default: v0.13.0 + default: v0.15.0 required: false output: description: "Summary output file path" @@ -56,7 +56,7 @@ runs: id: lychee env: # https://github.com/actions/runner/issues/665 - INPUT_GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} + INPUT_TOKEN: ${{ inputs.TOKEN }} INPUT_ARGS: ${{ inputs.ARGS }} INPUT_DEBUG: ${{ inputs.DEBUG }} INPUT_FAIL: ${{ inputs.FAIL }} diff --git a/entrypoint.sh b/entrypoint.sh index bfd46a5..0e560c7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -27,10 +27,8 @@ exit_code=$? if [ ! -f "${LYCHEE_TMP}" ]; then echo "No output. Check pipeline run to see if lychee panicked." > "${LYCHEE_TMP}" -fi - -# If we have any output, create a report in the designated directory -if [ -f "${LYCHEE_TMP}" ]; then +else + # If we have any output, create a report in the designated directory mkdir -p "$(dirname -- "${INPUT_OUTPUT}")" cat "${LYCHEE_TMP}" > "${INPUT_OUTPUT}"