Skip to content

Commit e3adb1b

Browse files
committed
chore: enhance links checker
1 parent b573745 commit e3adb1b

File tree

1 file changed

+47
-4
lines changed

1 file changed

+47
-4
lines changed

.github/workflows/ci-links.yml

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,52 @@ on:
66
schedule:
77
- cron: "0 18 * * *"
88

9+
env:
10+
BUILD_PATH: "."
11+
912
jobs:
1013
check_links:
1114
runs-on: ubuntu-latest
1215
steps:
13-
- uses: actions/checkout@v4
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup pnpm
20+
uses: pnpm/action-setup@v4
21+
22+
- name: Setup Node
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: "20"
26+
cache: "pnpm"
27+
cache-dependency-path: ${{ env.BUILD_PATH }}/pnpm-lock.yaml
28+
29+
- name: Install dependencies
30+
run: pnpm install --frozen-lockfile
31+
working-directory: ${{ env.BUILD_PATH }}
32+
33+
- name: Build with Astro
34+
run: pnpm build --site "http://localhost:4321"
35+
working-directory: ${{ env.BUILD_PATH }}
36+
37+
- name: Start Astro Preview in the background
38+
run: |
39+
pnpm preview &
40+
echo $! > astro-preview.pid
41+
working-directory: ${{ env.BUILD_PATH }}
42+
43+
- name: Wait for Astro to be ready
44+
run: |
45+
timeout 15 sh -c 'until curl -s http://localhost:4321 > /dev/null; do sleep 1; done'
1446
1547
- name: Link Checker
1648
id: lychee
1749
uses: lycheeverse/lychee-action@v1
1850
with:
19-
args: --base . --verbose --no-progress './**/*.md' './**/*.mdx' './**/*.html' './**/*.rst'
51+
args: --base ${{ env.BUILD_PATH }}/dist --verbose --no-progress --remap 'file:///home/runner/work/r.obin.ch/r.obin.ch/dist http://localhost:4321' './**/*.html'
52+
53+
- name: Stop Astro Preview
54+
run: kill $(cat astro-preview.pid)
2055

2156
- name: Find or Create Issue
2257
id: issue_finder
@@ -39,13 +74,21 @@ jobs:
3974
owner: context.repo.owner,
4075
repo: context.repo.repo,
4176
title: 'Link Checker Report',
42-
body: 'This issue tracks the broken links found by the link checker.',
77+
body: 'There are no broken links in the site or action did not run successfully.',
4378
labels: ['report', 'automated issue'],
4479
});
4580
issue = newIssue;
4681
console.log(`Created issue #${newIssue.number}`);
4782
} else {
48-
console.log(`Found existing issue #${issue.number}`);
83+
// If an issue with the title "Link Checker Report" already exists, update its body
84+
const { data: updatedIssue } = await github.rest.issues.update({
85+
owner: context.repo.owner,
86+
repo: context.repo.repo,
87+
issue_number: issue.number,
88+
body: 'There are no broken links in the site or action did not run successfully.',
89+
});
90+
issue = updatedIssue;
91+
console.log(`Updated issue #${issue.number}`);
4992
}
5093
5194
// Output the issue number to pass to the next steps

0 commit comments

Comments
 (0)