Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/activity-history-post.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Post Activity History to all Users

on:
schedule:
- cron: 45 22 9 8 *
- cron: 25 4 10 8 *
workflow_dispatch:

jobs:
Expand Down
12 changes: 10 additions & 2 deletions github-actions/activity-trigger/first-post-to-skills-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const postComment = require('../utils/post-issue-comment');
const checkTeamMembership = require('../utils/check-team-membership');
const statusFieldIds = require('../utils/_data/status-field-ids');
const mutateIssueStatus = require('../utils/mutate-issue-status');
const minimizeIssueComment = require('../utils/hide-issue-comment');
const getIssueComments = require('./get-issue-comments');

// Global variables
var github;
Expand All @@ -28,7 +30,7 @@ async function firstPostToSkillsIssue({g, c}) {


try {
const csvPath = 'github-actions/activity-trigger/member_activity_history_bot.csv';
const csvPath = 'github-actions/activity-trigger/member_activity_history_bot_1.csv';
const csvContent = fs.readFileSync(csvPath, 'utf-8');

// Parse CSV assuming
Expand All @@ -49,8 +51,14 @@ async function firstPostToSkillsIssue({g, c}) {

// Since we know this is the first run and no matching issue comments exist yet, we can post immediately
const body = `${MARKER}\n## Activity Log: ${username}\n\n##### ⚠ Important note: The bot updates this issue automatically - do not edit\n\n${message}`;
await postComment(github, context, skillsIssueNum, body);
await postComment(skillsIssueNum, body, github, context);

// Perform cleanup of comments
const commentIds = await getIssueComments(github, context, skillsIssueNum);
for (const commentId of commentIds) {
await minimizeIssueComment(github, commentId);
}

// Check whether eventActor is team member; if so open issue and move to "In progress"
const isActiveMember = await checkTeamMembership(github, username, team);

Expand Down
59 changes: 59 additions & 0 deletions github-actions/activity-trigger/get-issue-comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const tenDaysAgo = new Date();
tenDaysAgo.setDate(tenDaysAgo.getDate() - 10);


async function getIssueComments(github, context, issueNum) {

const owner = context.repo.owner;
const repo = context.repo.repo;


const query = `query($owner: String!, $repo: String!, $issueNum: Int!) {
repository(owner: $owner, name: $repo) {
issue(number: $issueNum) {
comments(first: 100) {
nodes {
id
author { login }
createdAt
isMinimized
minimizedReason
}
}
}
}
}`;

const variables = {
owner: owner,
repo: repo,
issueNum: issueNum,
};


let commentIds = [];
let botNames = ["github-actions[bot]", "HackforLABot"];

try {
const response = await github.graphql(query, variables);

let comments = response.repository.issue.comments.nodes || [];

for (let comment of comments) {
let created = new Date(comment.createdAt);

if (
botNames.includes(comment.author?.login) &&
created < tenDaysAgo &&
!comment.isMinimized
) {
commentIds.push(comment.id);
}
}
} catch (error) {
throw new Error(`Error retrieving comments for issue #${issueNum}: ${error}`);
}

return commentIds;
}

617 changes: 617 additions & 0 deletions github-actions/activity-trigger/member_activity_history_bot_1.csv

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,12 @@ function formatComment(assignees, labelString) {
function isCommentByBot(data) {
let botLogin = "github-actions[bot]";
let hflaBotLogin = "HackforLABot";
// If the comment includes the MARKER, return false
let MARKER = '<!-- Skills Issue Activity Record -->';
if (data.body.includes(MARKER)) {
console.log(`Found "Skills Issue Activity Record" - do not minimize`);
return false;
}
return data.actor.login === botLogin || data.actor.login === hflaBotLogin;
}

Expand Down
4 changes: 2 additions & 2 deletions github-actions/utils/_data/label-directory.json
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,8 @@
"Skill: enhance",
8273641077
],
"NEW-skillsIssueCompleted": [
"skillsIssueCompleted": [
"Skills Issue Completed",
9085307637
]
}
}