diff --git a/.github/workflows/wr-schedule-monthly.yml b/.github/workflows/wr-schedule-monthly.yml index c36357c15e..937ab831d4 100644 --- a/.github/workflows/wr-schedule-monthly.yml +++ b/.github/workflows/wr-schedule-monthly.yml @@ -6,12 +6,14 @@ on: types: [completed] permissions: - contents: read + contents: read jobs: Create-New-Issue: runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} + outputs: + issue_url: ${{ steps.create-new-issue.outputs.result }} steps: - run: echo "The 'Schedule Monthly' workflow succeeded. Continuing." - uses: actions/checkout@v6 @@ -23,8 +25,9 @@ jobs: with: github-token: ${{ secrets.HACKFORLA_BOT_PA_TOKEN }} script: | - const script = require('./github-actions/trigger-schedule/list-inactive-members/create-new-issue.js') - script({g: github, c: context}) + const script = require('./github-actions/trigger-schedule/list-inactive-members/create-new-issue.js'); + const newIssue = await script({g: github, c: context}); + return newIssue; Close-New-Issue: needs: Create-New-Issue @@ -32,34 +35,8 @@ jobs: steps: - uses: actions/checkout@v6 - - name: Get owner url - id: get-owner-url - uses: actions/github-script@v8 - with: - script: | - const ownerURL = context.payload.repository.html_url; - console.log("Owner url: " + ownerURL); - return ownerURL; - - # Then retrieve the latest issue created in the repo (i.e. by 'Schedule Monthly') - - name: Get issue number - id: get-issue-number - uses: actions/github-script@v8 - with: - script: | - const newIssue = await github.rest.issues.listForRepo({ - owner: context.repo.owner, - repo: context.repo.repo, - state:"all", - per_page: 1, - page: 1, - }); - const newIssueNumber = newIssue['data'][0]['number']; - console.log("Latest issue number: " + newIssueNumber); - return newIssueNumber; - - # Automatically close this last issue- that is, the issue just created by 'Schedule Monthly' + # Automatically close the issue that was just created - name: Auto close issue - run: gh issue close "${{ steps.get-owner-url.outputs.result }}/issues/${{ steps.get-issue-number.outputs.result }}" + run: gh issue close "${{ needs.Create-New-Issue.outputs.issue_url }}" env: GH_TOKEN: ${{ secrets.HACKFORLA_BOT_PA_TOKEN }} diff --git a/github-actions/trigger-schedule/list-inactive-members/create-new-issue.js b/github-actions/trigger-schedule/list-inactive-members/create-new-issue.js index a17c8fb2b7..8303d0498e 100644 --- a/github-actions/trigger-schedule/list-inactive-members/create-new-issue.js +++ b/github-actions/trigger-schedule/list-inactive-members/create-new-issue.js @@ -22,7 +22,7 @@ async function main({ g, c }) { // Retrieve lists data from json file written in previous step const filepath = 'github-actions/utils/_data/inactive-members.json'; const rawData = fs.readFileSync(filepath, 'utf8'); - let inactiveLists = JSON.parse(rawData); + const inactiveLists = JSON.parse(rawData); const inactiveWithOpen = parseInactiveOpen(inactiveLists['inactiveOpenIssue']); const nonTeamWithOpen = parseNonTeamOpen(inactiveLists['nonTeamOpenIssue']); @@ -36,34 +36,36 @@ async function main({ g, c }) { // Add issue number used to reference the issue and comment on the `Dev/PM Agenda and Notes` const commentBody = `**Review Inactive Team Members:** #` + issueNumber + inactiveWithOpen + nonTeamWithOpen; await postComment(AGENDA_ISSUE_NUM, commentBody, github, context); + + return issue.html_url; } const createIssue = async (owner, repo, inactiveLists) => { // Splits inactiveLists into lists of removed contributors and of those to be notified - let removeList = inactiveLists['removedContributors']; - let notifyList = inactiveLists['notifiedContributors']; + const removeList = inactiveLists['removedContributors']; + const notifyList = inactiveLists['notifiedContributors']; - let removedList = removeList.map(x => "@" + x).join("\n"); - let notifiedList = notifyList.map(x => "@" + x).join("\n"); + const removedList = removeList.map(x => "@" + x).join("\n"); + const notifiedList = notifyList.map(x => "@" + x).join("\n"); // This finds all issues in the repo and returns the only the number for the last issue created. // Add 1 to this issue number to get the number for the next issue- i.e. the one being created. - let thisIssuePredict = await github.rest.issues.listForRepo({ + const thisIssuePredict = await github.rest.issues.listForRepo({ owner, repo, state:"all", per_page: 1, page: 1, }); - let thisIssueNumber = thisIssuePredict['data'][0]['number'] + 1; + const thisIssueNumber = thisIssuePredict['data'][0]['number'] + 1; // Uses issueTemplateParser to pull the relevant data from the issue template const pathway = 'github-actions/trigger-schedule/list-inactive-members/inactive-members.md'; const issueObject = issueTemplateParser(pathway); - let title = issueObject['title']; - let labels = issueObject['labels']; - let milestone = parseInt(issueObject['milestone']); + const title = issueObject['title']; + const labels = issueObject['labels']; + const milestone = parseInt(issueObject['milestone']); let body = issueObject['body']; // Replace variables in issue template body diff --git a/github-actions/trigger-schedule/list-inactive-members/inactive-members.md b/github-actions/trigger-schedule/list-inactive-members/inactive-members.md index 02efe8f359..b167009028 100644 --- a/github-actions/trigger-schedule/list-inactive-members/inactive-members.md +++ b/github-actions/trigger-schedule/list-inactive-members/inactive-members.md @@ -2,7 +2,7 @@ name: Review Inactive Team Members about: Issue template used only by `schedule-monthly.yml` title: "Review Inactive Team Members" -labels: ['Feature: Administrative', 'Feature: Onboarding/Contributing.md', 'role: dev leads', 'Complexity: Small', 'size: 0.5pt'] +labels: ['Feature: Administrative', 'Feature: Onboarding/Contributing.md', 'role: dev leads', 'Complexity: Small', 'size: 0.5pt', 'non-PR contribution'] milestone: 8 assignees: '' --- diff --git a/github-actions/trigger-schedule/list-inactive-members/trim-inactive-members.js b/github-actions/trigger-schedule/list-inactive-members/trim-inactive-members.js index 945f7619de..5d6a4e93e7 100644 --- a/github-actions/trigger-schedule/list-inactive-members/trim-inactive-members.js +++ b/github-actions/trigger-schedule/list-inactive-members/trim-inactive-members.js @@ -95,7 +95,7 @@ async function removeInactiveMembers(previousContributors, inactiveWithOpenSkill removedMembers.push(username); // After removal, close member's "Skills Issue", if open if (username in inactiveWithOpenSkills) { - closePrework(username, inactiveWithOpenSkills[username]); + await closePrework(username, inactiveWithOpenSkills[username]); } } } @@ -215,11 +215,9 @@ function writeData(removedContributors, notifiedContributors, nonTeamOpenIssue, const filepath = 'github-actions/utils/_data/inactive-members.json'; const inactiveMemberLists = { removedContributors, notifiedContributors, nonTeamOpenIssue, inactiveOpenIssue }; - fs.writeFile(filepath, JSON.stringify(inactiveMemberLists, null, 2), (err) => { - if (err) throw err; - console.log(`-`.repeat(60)); - console.log("File `inactive-members.json` saved successfully!"); - }); + fs.writeFileSync(filepath, JSON.stringify(inactiveMemberLists, null, 2)); + console.log(`-`.repeat(60)); + console.log("File `inactive-members.json` saved successfully!"); } module.exports = main;