Skip to content

Commit 3e0a2ae

Browse files
committed
use mise file tasks
1 parent 2c41e66 commit 3e0a2ae

File tree

6 files changed

+66
-35
lines changed

6 files changed

+66
-35
lines changed

.github/workflows/reusable-link-check.yml

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,16 @@ jobs:
2020
if: github.event_name == 'pull_request'
2121
env:
2222
GITHUB_TOKEN: ${{ github.token }}
23-
run: mise run lint-local-links
24-
25-
- name: Get modified files
26-
if: github.event_name == 'pull_request'
27-
id: modified-files
28-
run: |
29-
merge_base=$(git merge-base origin/${{ github.base_ref }} HEAD)
30-
# Using lychee's default extension filter here to match when it runs against all files
31-
# Note: --diff-filter=d filters out deleted files
32-
modified_files=$(git diff --name-only --diff-filter=d $merge_base...${{ github.event.pull_request.head.sha }} \
33-
| grep -E '\.(md|mkd|mdx|mdown|mdwn|mkdn|mkdown|markdown|html|htm|txt)$' \
34-
| tr '\n' ' ' || true)
35-
echo "files=$modified_files" >> $GITHUB_OUTPUT
36-
echo "Modified files: $modified_files"
37-
38-
- name: Check if lychee config was modified
39-
if: github.event_name == 'pull_request'
40-
id: config-check
41-
run: |
42-
merge_base=$(git merge-base origin/${{ github.base_ref }} HEAD)
43-
config_modified=$(git diff --name-only $merge_base...${{ github.event.pull_request.head.sha }} \
44-
| grep -E '^(\.github/config/lychee\.toml|mise\.toml)$' || true)
45-
if [ -n "$config_modified" ]; then
46-
echo "modified=true" >> $GITHUB_OUTPUT
47-
fi
23+
run: mise run lint:local-links
4824

4925
- name: Link check (modified files only)
50-
if: github.event_name == 'pull_request' && steps.modified-files.outputs.files != '' && steps.config-check.outputs.modified != 'true'
26+
if: github.event_name == 'pull_request'
5127
env:
5228
GITHUB_TOKEN: ${{ github.token }}
53-
run: mise run lint-links ${{ steps.modified-files.outputs.files }}
29+
run: mise run lint:links-in-modified-file --base origin/${{ github.base_ref }} --head ${{ github.event.pull_request.head.sha }}
5430

5531
- name: Link check (all files)
56-
if: github.event_name != 'pull_request' || steps.config-check.outputs.modified == 'true'
32+
if: github.event_name != 'pull_request'
5733
env:
5834
GITHUB_TOKEN: ${{ github.token }}
59-
run: mise run lint-links
35+
run: mise run lint:links-if-config-changed

.mise/tasks/lint/links

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
#MISE description="Lint links in all files"
3+
4+
set -e
5+
6+
#USAGE arg "<file>" var=#true help="files to check" default="."
7+
8+
lychee --verbose --config .github/config/lychee.toml $usage_file
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
#MISE description="Lint links if lychee config changed"
3+
4+
set -e
5+
6+
#USAGE flag "--base <base>" help="base branch to compare against" default="origin/main"
7+
#USAGE flag "--head <head>" help="head branch to compare against" default="HEAD"
8+
9+
merge_base=$(git merge-base "$usage_base" HEAD)
10+
11+
# Check if lychee config was modified
12+
config_modified=$(git diff --name-only "$merge_base"..."$usage_head" \
13+
| grep -E '^(\.github/config/lychee\.toml|mise\.toml)$' || true)
14+
15+
if [ -z "$config_modified" ] ; then
16+
echo "No config changes, skipping link linting."
17+
exit 0
18+
fi
19+
20+
mise run lint:links
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
#MISE description="Lint links in modified files"
3+
4+
set -e
5+
6+
#USAGE flag "--base <base>" help="base branch to compare against" default="origin/main"
7+
#USAGE flag "--head <head>" help="head branch to compare against" default="HEAD"
8+
9+
merge_base=$(git merge-base "$usage_base" HEAD)
10+
# Using lychee's default extension filter here to match when it runs against all files
11+
# Note: --diff-filter=d filters out deleted files
12+
modified_files=$(git diff --name-only --diff-filter=d "$merge_base"..."$usage_head" \
13+
| grep -E '\.(md|mkd|mdx|mdown|mdwn|mkdn|mkdown|markdown|html|htm|txt)$' \
14+
| tr '\n' ' ' || true)
15+
16+
# Check if lychee config was modified
17+
config_modified=$(git diff --name-only "$merge_base"..."$usage_head" \
18+
| grep -E '^(\.github/config/lychee\.toml|mise\.toml)$' || true)
19+
20+
if [ -z "$modified_files" ] && [ -z "$config_modified" ] ; then
21+
echo "No modified files and no config changes, skipping link linting."
22+
exit 0
23+
fi
24+
25+
mise run lint-links "$modified_files"

.mise/tasks/lint/local-links

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
#MISE description="Lint links in all files"
3+
4+
set -e
5+
6+
#USAGE arg "<file>" var=#true help="files to check" default="."
7+
8+
lychee --verbose --scheme file --include-fragments $usage_file

mise.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
[tools]
22
lychee = "0.20.1"
33

4-
[tasks.lint-local-links]
5-
run = 'lychee --verbose --scheme file --include-fragments {{arg(name="files", default=".")}}'
6-
7-
[tasks.lint-links]
8-
run = 'lychee --verbose --config .github/config/lychee.toml {{arg(name="files", var=true, default=".")}}'
9-
104
[settings]
115
# Only install tools explicitly defined in the [tools] section above
126
idiomatic_version_file_enable_tools = []

0 commit comments

Comments
 (0)