Skip to content
Open
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
39 changes: 8 additions & 31 deletions .github/workflows/wr-schedule-monthly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,43 +25,18 @@ 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
runs-on: ubuntu-latest
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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}
Expand Down Expand Up @@ -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;
Loading