Skip to content

Commit

Permalink
ci: refactor issues and label workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Aetherinox committed Oct 13, 2024
1 parent 6ac445b commit b28a3fd
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 61 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/issues-scan.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# #
# @parent : github workflow
# @desc : pull request autoscan
# scans all of the files related to a particular pull request
# if the code in the files being submitted contains code that is forbidden,
# a report is generated and posted as a comment in the PR.
# @author : Aetherinox
# @url : https://github.com/Aetherinox
# @type github workflow
# @desc pull request autoscan
# scans all of the files related to a particular pull request
# if the code in the files being submitted contains code that is forbidden,
# a report is generated and posted as a comment in the PR.
# @author Aetherinox
# @url https://github.com/Aetherinox
# #

name: "🎫 Issues › Scan"
Expand Down
105 changes: 55 additions & 50 deletions .github/workflows/issues-stale.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# #
# @parent : github workflow
# @desc : checks each issue / PR for a valid label
# @author : Aetherinox
# @url : https://github.com/Aetherinox
# @type github workflow
# @desc creates repository labels if they are not yet installed
# issues marked as stale after 30 days, given tag Status 𐄂 Stale
# inactive issues closed after 180 days, given tag Status 𐄂 Locked
# inactive pr closed after 365 days, given tag Status 𐄂 Locked
# issues marked stale after 30 days, given tag Status 𐄂 Stale
# issues marked closed 7 days after being marked stale, given tag Status 𐄂 Autoclosed
# @author Aetherinox
# @url https://github.com/Aetherinox
#
# This Github action must be activated manually. This workflow script will do the
# following:
Expand Down Expand Up @@ -270,9 +275,9 @@ jobs:
Change last number ( 36 = hours )
*/
const expireAfterMs = 1000 * 60 * 60 * 36; // milliseconds ( 36 hours )
const curtime = new Date( ).getTime( ); // 1711471510629
const issues = await github.rest.issues.listForRepo( { owner: context.repo.owner, repo: context.repo.repo, state: 'open' } );
const expireAfterMs = 1000 * 60 * 60 * 36; // milliseconds ( 36 hours )
const curtime = new Date( ).getTime( ); // 1711471510629
const issues = await github.rest.issues.listForRepo( { owner: context.repo.owner, repo: context.repo.repo, state: 'open' } );
console.log( ` 📦── Found ${issues.data.length} open issues` );
Expand Down Expand Up @@ -338,7 +343,7 @@ jobs:
Label > Bugs
*/
const bug_bIncWordT = bug_words.some( s => s.includes( iss_title_lc ) || iss_title_lc.includes( s ) );
const bug_bIncWordT = bug_words.some( s => s.includes( iss_title_lc ) || iss_title_lc.includes( s ) );
/*
Find regex based phrases
Expand All @@ -347,9 +352,9 @@ jobs:
https://regex101.com/r/Z99Gnq/2
*/
const bug_findWordList = /^\b(?:I?\s*have\s*(?:a|an)\s*(?:issue|problem|bug))|(?:will\s*not\s*work)|(?:it\s*is\s*(?:broken|broke|stuck))|(?:found\s*(?:an?|the)\s*(?:bug|issue))|(?:can\s*I\s*fix\s*the\s*(?:bug|issue))|(?:(?:does not|doesn'?t|don'?t|won'?t|can'?t|can\s?not|will\s*not)\s*(?:work|load|function))|(?:it\s*(?:will\s?not|won'?t|can\s?not|can'?t))\s*(?:get|find)\s*the\s*(?:website|site|webpage|page)|(?:the\s*(?:window|frame)\s*is\s*(?:blank|white|empty|missing))\b$/igm;
const bug_bFoundMatchTitle = Boolean( bug_findWordList.test( iss_title ) );
const bug_bFoundMatchBody = Boolean( bug_findWordList.test( iss_body ) );
const bug_findWordList = /^\b(?:I?\s*have\s*(?:a|an)\s*(?:issue|problem|bug))|(?:will\s*not\s*work)|(?:it\s*is\s*(?:broken|broke|stuck))|(?:found\s*(?:an?|the)\s*(?:bug|issue))|(?:can\s*I\s*fix\s*the\s*(?:bug|issue))|(?:(?:does not|doesn'?t|don'?t|won'?t|can'?t|can\s?not|will\s*not)\s*(?:work|load|function))|(?:it\s*(?:will\s?not|won'?t|can\s?not|can'?t))\s*(?:get|find)\s*the\s*(?:website|site|webpage|page)|(?:the\s*(?:window|frame)\s*is\s*(?:blank|white|empty|missing))\b$/igm;
const bug_bFoundMatchTitle = Boolean( bug_findWordList.test( iss_title ) );
const bug_bFoundMatchBody = Boolean( bug_findWordList.test( iss_body ) );
/*
Do not change a title if the item starts with a PR: #
Expand All @@ -358,8 +363,8 @@ jobs:
https://regex101.com/r/JOrqbN/1
*/
const bug_findPRTitle = /^PR\s?#?(?:[0-9]*:)/igm;
const bug_bFoundPRTitle = Boolean( bug_findPRTitle.test( iss_title ) );
const bug_findPRTitle = /^PR\s?#?(?:[0-9]*:)/igm;
const bug_bFoundPRTitle = Boolean( bug_findPRTitle.test( iss_title ) );
/*
- Check if issue title matches the issue label "Bug:"
Expand All @@ -377,11 +382,11 @@ jobs:
// Rename title to contain Bug:
if ( author !== `${{ env.BOT_NAME_DEPENDABOT }}` && !bug_bFoundPRTitle && !iss_title_lc.startsWith( bug_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( feat_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( urgn_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( road_tag.toLowerCase( ) ) )
{
const title = issue.title;
let title_new = title.replace( /^\s?bug\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?fail\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?issue\s*(.*?)\b/gi, '' );
iss_title = `${ bug_tag } ${ title_new }`;
const title = issue.title;
let title_new = title.replace( /^\s?bug\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?fail\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?issue\s*(.*?)\b/gi, '' );
iss_title = `${ bug_tag } ${ title_new }`;
}
await github.rest.issues.update(
Expand All @@ -395,7 +400,7 @@ jobs:
Label > Features
*/
const feat_bIncWordT = feat_words.some( s => s.includes( iss_title_lc ) || iss_title_lc.includes( s ) );
const feat_bIncWordT = feat_words.some( s => s.includes( iss_title_lc ) || iss_title_lc.includes( s ) );
/*
Find regex based phrases
Expand All @@ -404,7 +409,7 @@ jobs:
https://regex101.com/r/fR1Hm6/1
*/
const feat_findWordList = /^(?:(?:request|include|see)\s*(?:an?|the?)\s*(?:feature|addon|addition|plugin))|(?:(?:add|see|get)\s*support\s*(?:for|with|of))|(?:can\s*we\s*get\s*(?:the|a)\s*(?:ability|feature))|(?:💡 Feature:)$/igm;
const feat_findWordList = /^(?:(?:request|include|see)\s*(?:an?|the?)\s*(?:feature|addon|addition|plugin))|(?:(?:add|see|get)\s*support\s*(?:for|with|of))|(?:can\s*we\s*get\s*(?:the|a)\s*(?:ability|feature))|(?:💡 Feature:)$/igm;
const feat_bFoundMatchTitle = Boolean( feat_findWordList.test( iss_title ) );
const feat_bFoundMatchBody = Boolean( feat_findWordList.test( iss_body ) );
Expand Down Expand Up @@ -434,12 +439,12 @@ jobs:
// Rename title to contain Feature:
if ( author !== `${{ env.BOT_NAME_DEPENDABOT }}` && !feat_bFoundPRTitle && !iss_title_lc.startsWith( bug_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( feat_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( urgn_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( road_tag.toLowerCase( ) ) )
{
const title = issue.title;
let title_new = title.replace( /^\s?feature\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?request\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?add(.*?)\s?feature\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?add(.*?)\s?support\s*(.*?)\b/gi, '' );
iss_title = `${ feat_tag } ${ title_new }`;
const title = issue.title;
let title_new = title.replace( /^\s?feature\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?request\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?add(.*?)\s?feature\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?add(.*?)\s?support\s*(.*?)\b/gi, '' );
iss_title = `${ feat_tag } ${ title_new }`;
}
await github.rest.issues.update(
Expand All @@ -453,7 +458,7 @@ jobs:
Label > Urgent
*/
const urgn_bIncWordT = urgn_words.some( s => s.includes( iss_title_lc ) || iss_title_lc.includes( s ) );
const urgn_bIncWordT = urgn_words.some( s => s.includes( iss_title_lc ) || iss_title_lc.includes( s ) );
/*
Find regex based phrases
Expand All @@ -462,9 +467,9 @@ jobs:
https://regex101.com/r/eE9tJX/2
*/
const urgn_findWordList = /(?:(?:this)?is\s*a?n?\s*?(?:emergency|urgent|important|vital|acute|crucial|grave|pressing|serious|top.?priority|high.?priority))|(?:reply|respond|answer|write|address)\s*(?:immediate|quick|asap|urgent|now|fast|(?:as)?\s*(?:soon|quick|immediate|fast))(?:ly)?|(?:need\s*(?:help|support|fixed|answer|reply|response)!)|(?:emergency|critical|urgen(?:t|cy)|high.?priority)/igm;
const urgn_bFoundMatchTitle = Boolean( urgn_findWordList.test( iss_title ) );
const urgn_bFoundMatchBody = Boolean( urgn_findWordList.test( iss_body ) );
const urgn_findWordList = /(?:(?:this)?is\s*a?n?\s*?(?:emergency|urgent|important|vital|acute|crucial|grave|pressing|serious|top.?priority|high.?priority))|(?:reply|respond|answer|write|address)\s*(?:immediate|quick|asap|urgent|now|fast|(?:as)?\s*(?:soon|quick|immediate|fast))(?:ly)?|(?:need\s*(?:help|support|fixed|answer|reply|response)!)|(?:emergency|critical|urgen(?:t|cy)|high.?priority)/igm;
const urgn_bFoundMatchTitle = Boolean( urgn_findWordList.test( iss_title ) );
const urgn_bFoundMatchBody = Boolean( urgn_findWordList.test( iss_body ) );
/*
Do not change a title if the item starts with a PR: #
Expand Down Expand Up @@ -492,13 +497,13 @@ jobs:
// Rename title to contain Urgent:
if ( author !== `${{ env.BOT_NAME_DEPENDABOT }}` && !urgn_bFoundPRTitle && !iss_title_lc.startsWith( bug_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( feat_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( urgn_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( road_tag.toLowerCase( ) ) )
{
const title = issue.title;
let title_new = title.replace( /^\s?emergency\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?urgent\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?urgency\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?important\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?critical\s*(.*?)\b/gi, '' );
iss_title = `${ urgn_tag } ${ title_new }`;
const title = issue.title;
let title_new = title.replace( /^\s?emergency\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?urgent\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?urgency\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?important\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?critical\s*(.*?)\b/gi, '' );
iss_title = `${ urgn_tag } ${ title_new }`;
}
await github.rest.issues.update(
Expand All @@ -522,9 +527,9 @@ jobs:
https://regex101.com/r/ucajBZ/1
*/
const road_findWordList = /#\s*Summary[\S\s]+#\s*(?:Proposal|Objective)[^\]]+/igm;
const road_bFoundMatchTitle = Boolean( road_findWordList.test( iss_title ) );
const road_bFoundMatchBody = Boolean( road_findWordList.test( iss_body ) );
const road_findWordList = /#\s*Summary[\S\s]+#\s*(?:Proposal|Objective)[^\]]+/igm;
const road_bFoundMatchTitle = Boolean( road_findWordList.test( iss_title ) );
const road_bFoundMatchBody = Boolean( road_findWordList.test( iss_body ) );
/*
Do not change a title if the item starts with a PR: #
Expand All @@ -533,8 +538,8 @@ jobs:
https://regex101.com/r/JOrqbN/1
*/
const road_findPRTitle = /^PR\s?#?(?:[0-9]*:)/igm;
const road_bFoundPRTitle = Boolean( road_findPRTitle.test( iss_title ) );
const road_findPRTitle = /^PR\s?#?(?:[0-9]*:)/igm;
const road_bFoundPRTitle = Boolean( road_findPRTitle.test( iss_title ) );
/*
- Check if issue title matches the issue label "Roadmap:"
Expand All @@ -552,13 +557,13 @@ jobs:
// Rename title to contain Roadmap:
if ( author !== `${{ env.BOT_NAME_DEPENDABOT }}` && !road_bFoundPRTitle && !iss_title_lc.startsWith( bug_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( feat_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( urgn_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( road_tag.toLowerCase( ) ) )
{
const title = issue.title;
let title_new = title.replace( /^\s?emergency\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?urgent\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?urgency\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?important\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?critical\s*(.*?)\b/gi, '' );
iss_title = `${ road_tag } ${ title_new }`;
const title = issue.title;
let title_new = title.replace( /^\s?emergency\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?urgent\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?urgency\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?important\s*(.*?)\b/gi, '' );
title_new = title.replace( /^\s?critical\s*(.*?)\b/gi, '' );
iss_title = `${ road_tag } ${ title_new }`;
}
await github.rest.issues.update(
Expand Down Expand Up @@ -617,7 +622,7 @@ jobs:
<sub>I am a bot reaching out to you with an automated response.</sub>
stale-issue-label: 'Status 𐄂 Stale'
close-issue-label: 'Status 𐄂 '
close-issue-label: 'Status 𐄂 Autoclosed'
exempt-issue-labels: 'feature,Type ◦ Feature,bug,Type ◦ Bug'
days-before-stale: 30
days-before-close: 7
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/labels-create.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# #
# @parent : github workflow
# @desc : manually activated workflow to create issue labels
# @author : Aetherinox
# @url : https://github.com/Aetherinox
# @type github workflow
# @desc manually activated workflow to create issue labels
# @author Aetherinox
# @url https://github.com/Aetherinox
#
# This Github action must be activated manually. This workflow script will do the
# following:
Expand Down

0 comments on commit b28a3fd

Please sign in to comment.