Skip to content

Commit 4250060

Browse files
committed
refactor: centralize broken-markdown-links and automated labels (#2130)
Signed-off-by: Ajay Rajera <newajay.11r@gmail.com>
1 parent cbddff0 commit 4250060

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

.github/scripts/cron-admin-update-spam-list.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
const fs = require('fs').promises;
11+
const { LABEL_AUTOMATED } = require('./labels.js');
1112

1213
const SPAM_LIST_PATH = '.github/spam-list.txt';
1314
const dryRun = (process.env.DRY_RUN || 'false').toString().toLowerCase() === 'true';
@@ -229,7 +230,7 @@ module.exports = async ({github, context, core}) => {
229230
repo,
230231
title,
231232
body,
232-
labels: [LABEL_SPAM_LIST_UPDATE, 'automated']
233+
labels: [LABEL_SPAM_LIST_UPDATE, LABEL_AUTOMATED]
233234
});
234235
console.log('Issue created successfully');
235236
}

.github/scripts/labels.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Central location for label definitions to facilitate future changes.
3+
* This file serves as the single source of truth for all GitHub label names used by automated workflows.
4+
*/
5+
const LABEL_BROKEN_MARKDOWN_LINKS = 'notes: broken markdown links';
6+
const LABEL_AUTOMATED = 'notes: automated';
7+
8+
module.exports = {
9+
LABEL_BROKEN_MARKDOWN_LINKS,
10+
LABEL_AUTOMATED
11+
};

.github/workflows/cron-pr-check-broken-links.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Cron – Check Broken Markdown Links
22

3+
concurrency:
4+
group: cron-check-broken-markdown-links
5+
cancel-in-progress: false
6+
37
on:
48
schedule:
59
- cron: "0 0 1 * *"
@@ -42,12 +46,14 @@ jobs:
4246
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
4347
with:
4448
script: |
49+
const { LABEL_BROKEN_MARKDOWN_LINKS, LABEL_AUTOMATED } = require('./.github/scripts/labels.js');
50+
4551
// Determine if this is a dry run
4652
const isManual = context.eventName === 'workflow_dispatch';
47-
const dryRun = isManual ? String(context.payload.inputs.dry_run).toLowerCase() === 'true' : false;
53+
const dryRun = isManual ? String(context.payload?.inputs?.dry_run).toLowerCase() === 'true' : false;
4854
4955
// Labels configuration
50-
const targetLabels = ['broken-markdown-links', 'automated'];
56+
const targetLabels = [LABEL_BROKEN_MARKDOWN_LINKS, LABEL_AUTOMATED];
5157
const issueTitle = "Scheduled Markdown Link Check Found Broken Links";
5258
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
5359

0 commit comments

Comments
 (0)