Skip to content

Commit 3ce4c4e

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

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ jobs:
2424

2525
- name: Link check (modified files only)
2626
if: github.event_name == 'pull_request'
27+
# todo only if config did not change
2728
env:
2829
GITHUB_TOKEN: ${{ github.token }}
2930
run: mise run lint:links-in-modified-file --base origin/${{ github.base_ref }} --head ${{ github.event.pull_request.head.sha }}
3031

32+
# todo one stop commend for linting that also works locally: lint:modified-links
33+
3134
- name: Link check (all files)
35+
# todo also if not PR but config changed
3236
if: github.event_name != 'pull_request'
3337
env:
3438
GITHUB_TOKEN: ${{ github.token }}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
set -e
55

66
#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"
7+
#USAGE flag "--head <head>" help="head branch to compare against" default=""
88

9-
merge_base=$(git merge-base "$usage_base" HEAD)
9+
if [ "$usage_head" == "''" ]; then
10+
usage_head=""
11+
fi
12+
13+
# todo use .mise/tasks/lint/* for config change detection
1014

1115
# Check if lychee config was modified
12-
config_modified=$(git diff --name-only "$merge_base"..."$usage_head" \
16+
config_modified=$(git diff --name-only --merge_base "$usage_base" $usage_head \
1317
| grep -E '^(\.github/config/lychee\.toml|mise\.toml)$' || true)
1418

1519
if [ -z "$config_modified" ] ; then
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
#!/usr/bin/env bash
22
#MISE description="Lint links in modified files"
33

4-
set -e
4+
set -ex
55

66
#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"
7+
#USAGE flag "--head <head>" help="head branch to compare against" default=""
8+
9+
if [ "$usage_head" == "''" ]; then
10+
usage_head=""
11+
fi
812

9-
merge_base=$(git merge-base "$usage_base" HEAD)
1013
# Using lychee's default extension filter here to match when it runs against all files
1114
# Note: --diff-filter=d filters out deleted files
12-
modified_files=$(git diff --name-only --diff-filter=d "$merge_base"..."$usage_head" \
15+
modified_files=$(git diff --name-only --diff-filter=d "$usage_base" $usage_head \
1316
| grep -E '\.(md|mkd|mdx|mdown|mdwn|mkdn|mkdown|markdown|html|htm|txt)$' \
1417
| tr '\n' ' ' || true)
1518

1619
# Check if lychee config was modified
17-
config_modified=$(git diff --name-only "$merge_base"..."$usage_head" \
20+
config_modified=$(git diff --name-only --merge-base "$usage_base" $usage_head \
1821
| grep -E '^(\.github/config/lychee\.toml|mise\.toml)$' || true)
1922

2023
if [ -z "$modified_files" ] && [ -z "$config_modified" ] ; then
2124
echo "No modified files and no config changes, skipping link linting."
2225
exit 0
2326
fi
2427

25-
mise run lint-links "$modified_files"
28+
mise run lint:links $modified_files

0 commit comments

Comments
 (0)