Skip to content

Commit

Permalink
7078 post pbb migration refactor schedule friday workflow (#7260)
Browse files Browse the repository at this point in the history
* Refactor "Schedule Friday" workflow

* Remove import `statusFieldIds`

* fix improper JSDoc
  • Loading branch information
mrodz authored Aug 16, 2024
1 parent 3867c16 commit c233f9b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/schedule-fri-0700.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
env:
HACKFORLA_ADMIN_TOKEN: ${{ secrets.HACKFORLA_ADMIN_TOKEN }}
with:
github-token: ${{ secrets.HACKFORLA_GRAPHQL_TOKEN }}
script: |
const HACKFORLA_ADMIN_TOKEN = process.env.HACKFORLA_ADMIN_TOKEN;
const script = require('./github-actions/trigger-schedule/add-update-label-weekly/add-label.js');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// Import modules
const fs = require("fs");
const https = require("https");
const queryIssueInfo = require("../../utils/query-issue-info");
const findLinkedIssue = require('../../utils/find-linked-issue');
const getTimeline = require('../../utils/get-timeline');

Expand Down Expand Up @@ -33,7 +34,7 @@ var projectBoardToken;
* last update was not between 7 to 14 days ago, apply the appropriate label and request an update. However, if the assignee has submitted
* a PR that will fix the issue regardless of when, all update-related labels should be removed.
* @param {Object} g - github object from actions/github-script
* @param {Object} g - GitHub object from actions/github-script
* @param {Object} c - context object from actions/github-script
* @param {String} projectBoardToken - the Personal Access Token for the action
*/
Expand Down Expand Up @@ -80,12 +81,13 @@ async function main({ g, c }, pbt) {


/**
* Function that returns issue numbers of all issues in a repo
* Finds issue numbers for all open & assigned issues, excluding issues labeled `Draft`, `ER`, `Epic`,
* or `Dependency`, and returning issue numbers only if their status === "In progess (actively working"
*
* @returns an Array of issue numbers
* @returns {Promise<Array>} issueNums - an array of open, assigned, and statused issue numbers
*/
async function getIssueNumsFromRepo() {
const labelsToExclude = ['Draft', 'ER', 'Epic'];
const labelsToExclude = ['Draft', 'ER', 'Epic', 'Dependency'];
let issueNums = [];
let pageNum = 1;
let result = [];
Expand All @@ -94,6 +96,7 @@ async function getIssueNumsFromRepo() {
const issueData = await github.request('GET /repos/{owner}/{repo}/issues', {
owner: context.repo.owner,
repo: context.repo.repo,
assignee: '*',
per_page: 100,
page: pageNum,
});
Expand All @@ -106,17 +109,17 @@ async function getIssueNumsFromRepo() {
}
}

for (let issueNum of result) {
if (issueNum.number) {
let issueLabels = [];
for (let label of issueNum.labels) {
issueLabels.push(label.name);
}
if (!issueLabels.some(item => labelsToExclude.includes(item))) {
issueNums.push(issueNum.number);
} else {
console.log(`Excluding Issue #${issueNum.number} because of label`);
}
for (let { number, labels } of result) {
if (!number) continue;

// Exclude any issues that have excluded labels
const issueLabels = labels.map((label) => label.name);
if (issueLabels.some((item) => labelsToExclude.includes(item))) continue;

// For remaining issues, check if status === "In progress (actively working)"
const { statusName } = await queryIssueInfo(github, context, number);
if (statusName === "In progress (actively working)") {
issueNums.push(number);
}
}
return issueNums;
Expand Down

0 comments on commit c233f9b

Please sign in to comment.