From e539aa79f7f6e26d3a050a9ad8f852c0bda54ab9 Mon Sep 17 00:00:00 2001 From: Yu-Ting Hsiung Date: Thu, 20 Aug 2026 23:05:22 +0800 Subject: [PATCH] ci(links): avoid duplicate broken link reports Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/links.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml index b541439f02..392e20d30c 100644 --- a/.github/workflows/links.yml +++ b/.github/workflows/links.yml @@ -28,14 +28,29 @@ jobs: with: script: | const fs = require('fs'); + const reportTitle = 'Broken Links Report'; + const openIssues = await github.paginate( + github.rest.issues.listForRepo, + { + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + per_page: 100 + } + ); + + if (openIssues.some(issue => + !issue.pull_request && issue.title === reportTitle + )) { + core.info(`An open "${reportTitle}" issue already exists; skipping.`); + return; + } - // Read the markdown file - // Ensure the path is correct relative to the workspace root const reportBody = fs.readFileSync('./lychee/out.md', 'utf8'); await github.rest.issues.create({ owner: context.repo.owner, repo: context.repo.repo, - title: 'Broken Links Report', + title: reportTitle, body: reportBody });