FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix locked issue crash + robustness changes by SableRaf · Pull Request #6308 · processing/processing · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .yml  (1) All 1 file type selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
142 changes: 90 additions & 52 deletions .github/workflows/lock.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
- cron: '0 6 * * *'
workflow_dispatch:

concurrency:
group: close-old-threads
cancel-in-progress: false

permissions:
issues: write
pull-requests: write
Expand All @@ -23,23 +27,48 @@ jobs:
const cutoff = new Date();
cutoff.setDate(cutoff.getDate() - cutoffDays);

const closeIssueMessage = `This issue has been automatically closed and locked.

Processing 3.x is no longer actively developed. Since January 2020, development moved to the Processing 4 repository.

If this issue is still relevant to Processing 4, we'd love to hear from you. Please open a new issue at:
https://github.com/processing/processing4/issues/new/choose

Thank you for helping improve Processing.`;

const closePrMessage = `This pull request has been automatically closed and locked.

Processing 3.x is no longer actively developed. Since January 2020, development moved to the Processing 4 repository.

If you'd still like to contribute this work, please open an issue in the Processing 4 repository to discuss it first:
https://github.com/processing/processing4/issues/new/choose
const closeIssueMessage = [
'This issue has been automatically closed and locked.',
'',
'Processing 3.x is no longer actively developed. Since January 2020, development moved to the Processing 4 repository.',
'',
"If this issue is still relevant to Processing 4, we'd love to hear from you. Please open a new issue at:",
'https://github.com/processing/processing4/issues/new/choose',
'',
'Thank you for helping improve Processing.'
].join('\n');

const closePrMessage = [
'This pull request has been automatically closed and locked.',
'',
'Processing 3.x is no longer actively developed. Since January 2020, development moved to the Processing 4 repository.',
'',
"If you'd still like to contribute this work, please open an issue in the Processing 4 repository to discuss it first:",
'https://github.com/processing/processing4/issues/new/choose',
'',
'Thank you for your contribution.'
].join('\n');

async function closeThread(thread) {
const isPr = Boolean(thread.pull_request);

Thank you for your contribution.`;
if (isPr) {
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: thread.number,
state: 'closed'
});
} else {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: thread.number,
state: 'closed',
state_reason: 'not_planned'
});
}
}

const threads = await github.paginate(github.rest.issues.listForRepo, {
owner: context.repo.owner,
Expand All @@ -51,41 +80,50 @@ jobs:
});

for (const thread of threads) {
const updatedAt = new Date(thread.updated_at);

if (updatedAt > cutoff) {
continue;
}

const labels = thread.labels.map(label => label.name);
const isExempt = labels.some(label => exemptLabels.includes(label));

if (isExempt) {
continue;
try {
const updatedAt = new Date(thread.updated_at);

if (updatedAt > cutoff) {
break;
}

const labels = thread.labels.map(label =>
typeof label === 'string' ? label : label.name
);

const isExempt = labels.some(label => exemptLabels.includes(label));

if (isExempt) {
console.log(`Skipping #${thread.number}: exempt label.`);
continue;
}

const isPr = Boolean(thread.pull_request);
const body = isPr ? closePrMessage : closeIssueMessage;

await closeThread(thread);

if (thread.locked) {
console.log(`Closed #${thread.number}: already locked, so no comment was added.`);
continue;
}

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: thread.number,
body
});

await github.rest.issues.lock({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: thread.number,
lock_reason: 'resolved'
});

console.log(`Closed and locked #${thread.number}.`);
} catch (error) {
console.log(`Failed on #${thread.number}: ${error.status || 'unknown status'} ${error.message}`);
}

const isPr = Boolean(thread.pull_request);
const body = isPr ? closePrMessage : closeIssueMessage;

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: thread.number,
body
});

await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: thread.number,
state: 'closed',
state_reason: 'not_planned'
});

await github.rest.issues.lock({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: thread.number,
lock_reason: 'resolved'
});
}

Back | FazBrowse Home | New Git URL