Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions .github/local-actions/lock-closed/lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ import {
} from '../../../../github-actions/utils.js';
import {setTimeout as setTimeoutPromise} from 'timers/promises';

/**
* The URL of the policy. This is used to link to the policy from the lock message.
*/
const POLICY_URL =
'https://github.com/angular/angular/blob/f0fbced1c55bc8b8ed9df01cea99df42f3e7eae3/contributing-docs/auto-issue-locking.md';

/**
* Generates a lock message for a GitHub issue or pull request.
* @param itemType The type of the item, either 'pull request' or 'issue'.
* @returns The lock message string.
*/
function getLockMessage(itemType: 'pull request' | 'issue'): string {
return `${itemType.charAt(0).toUpperCase() + itemType.slice(1)} has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our [automatic conversation locking policy](${POLICY_URL}).

<sub>_This action has been performed automatically by a bot._</sub>`;
}

async function lockIssue(
client: Octokit,
issue: number,
Expand Down Expand Up @@ -58,15 +78,6 @@ async function runLockClosedAction(github: Octokit, repo: string): Promise<void>

// Fixed amount of days a closed issue must be inactive before being locked
const days = 30;
// Standardized Angular Team message for locking issues
const policyUrl =
'https://github.com/angular/angular/blob/f0fbced1c55bc8b8ed9df01cea99df42f3e7eae3/contributing-docs/auto-issue-locking.md';
const message =
'This issue has been automatically locked due to inactivity.\n' +
'Please file a new issue if you are encountering a similar or related problem.\n\n' +
`Read more about our [automatic conversation locking policy](${policyUrl}).\n\n` +
'<sub>_This action has been performed automatically by a bot._</sub>';

// Set the threshold date based on the days inactive
const threshold = new Date();
threshold.setDate(threshold.getDate() - days);
Expand Down Expand Up @@ -100,6 +111,7 @@ async function runLockClosedAction(github: Octokit, repo: string): Promise<void>
continue;
}
console.info(`Locking ${itemType} #${item.number}`);
const message = getLockMessage(itemType);
await lockIssue(github, item.number, repo, message);
await setTimeoutPromise(250);
++lockCount;
Expand Down
19 changes: 11 additions & 8 deletions .github/local-actions/lock-closed/main.js

Large diffs are not rendered by default.