Skip to content

Commit 004c4d5

Browse files
committed
use mise file tasks
1 parent 3ce4c4e commit 004c4d5

File tree

3 files changed

+22
-47
lines changed

3 files changed

+22
-47
lines changed

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@ jobs:
2323
run: mise run lint:local-links
2424

2525
- name: Link check (modified files only)
26-
if: github.event_name == 'pull_request'
27-
# todo only if config did not change
28-
env:
29-
GITHUB_TOKEN: ${{ github.token }}
30-
run: mise run lint:links-in-modified-file --base origin/${{ github.base_ref }} --head ${{ github.event.pull_request.head.sha }}
31-
32-
# todo one stop commend for linting that also works locally: lint:modified-links
33-
34-
- name: Link check (all files)
35-
# todo also if not PR but config changed
36-
if: github.event_name != 'pull_request'
3726
env:
3827
GITHUB_TOKEN: ${{ github.token }}
39-
run: mise run lint:links-if-config-changed
28+
run: mise run lint:links-in-modified-file --base origin/${{ github.base_ref }} --head ${{ github.event.pull_request.head.sha }} --event ${{ github.event_name }}

.mise/tasks/lint/links-if-config-changed

Lines changed: 0 additions & 24 deletions
This file was deleted.

.mise/tasks/lint/links-in-modified-files

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
#!/usr/bin/env bash
22
#MISE description="Lint links in modified files"
33

4-
set -ex
4+
set -e
55

66
#USAGE flag "--base <base>" help="base branch to compare against" default="origin/main"
77
#USAGE flag "--head <head>" help="head branch to compare against" default=""
8+
#USAGE flag "--event <event>" help="PR name" default="pull_request"
89

910
if [ "$usage_head" == "''" ]; then
1011
usage_head=""
1112
fi
1213

13-
# Using lychee's default extension filter here to match when it runs against all files
14-
# Note: --diff-filter=d filters out deleted files
15-
modified_files=$(git diff --name-only --diff-filter=d "$usage_base" $usage_head \
16-
| grep -E '\.(md|mkd|mdx|mdown|mdwn|mkdn|mkdown|markdown|html|htm|txt)$' \
17-
| tr '\n' ' ' || true)
18-
1914
# Check if lychee config was modified
2015
config_modified=$(git diff --name-only --merge-base "$usage_base" $usage_head \
21-
| grep -E '^(\.github/config/lychee\.toml|mise\.toml)$' || true)
16+
| grep -E '^(\.github/config/lychee\.toml|.mise/tasks/lint|mise\.toml)$' || true)
2217

23-
if [ -z "$modified_files" ] && [ -z "$config_modified" ] ; then
24-
echo "No modified files and no config changes, skipping link linting."
18+
if [ -n "$config_modified" ] ; then
19+
echo "config changes, checking all files."
20+
mise run lint:links
21+
elif [ "$usage_event" != "pull_request" ] ; then
22+
echo "Not a PR - skipping link linting."
2523
exit 0
24+
else
25+
# Using lychee's default extension filter here to match when it runs against all files
26+
# Note: --diff-filter=d filters out deleted files
27+
modified_files=$(git diff --name-only --diff-filter=d "$usage_base" $usage_head \
28+
| grep -E '\.(md|mkd|mdx|mdown|mdwn|mkdn|mkdown|markdown|html|htm|txt)$' \
29+
| tr '\n' ' ' || true)
30+
31+
if [ -z "$modified_files" ]; then
32+
echo "No modified files, skipping link linting."
33+
exit 0
34+
fi
35+
36+
mise run lint:links $modified_files
2637
fi
2738

28-
mise run lint:links $modified_files

0 commit comments

Comments
 (0)