Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b2830e2
Update activity-trigger.yml line 25
xnealcarson Oct 3, 2025
e458fc4
Add files via upload
xnealcarson Oct 11, 2025
7217292
Update post-to-skills-issue.js
xnealcarson Oct 11, 2025
1ac174c
Update post-to-skills-issue.js
xnealcarson Oct 11, 2025
7dbcad2
Add files via upload
xnealcarson Oct 11, 2025
0c0a75f
Rename skillsIssueNums-8-22.json to skills-directory.json
xnealcarson Oct 11, 2025
02cbaf3
Update post-to-skills-issue.js
xnealcarson Oct 11, 2025
b1b2957
Created skills-directory.js
xnealcarson Oct 11, 2025
397308f
Merge branch 'hackforla:gh-pages' into TEST-for-skillsactivity-GHA
xnealcarson Oct 12, 2025
0e57320
Update activity-trigger.yml: changed line 25 back to original state
xnealcarson Oct 13, 2025
23c0730
Update post-to-skills-issue.js changed lines of code edited for testi…
xnealcarson Oct 13, 2025
37aa0fe
Merge branch 'hackforla:gh-pages' into enhance-gha-skillsactivity-8316
xnealcarson Oct 18, 2025
ba56356
Update post-to-skills-issue.js line 55
xnealcarson Oct 18, 2025
ba6a687
Deleted github-actions/utils/_data/skillsIssueNums-8-22.csv
xnealcarson Oct 18, 2025
459b847
Update post-to-skills-issue.js to reflect ryanfkeller's requested cha…
xnealcarson Oct 26, 2025
38f2c6a
Merge branch 'hackforla:gh-pages' into enhance-gha-skillsactivity-8316
xnealcarson Nov 2, 2025
e4174a7
Update skills-directory.json to reflect latest skills directory updat…
xnealcarson Nov 2, 2025
104fb5c
Update post-to-skills-issue.js lines 54-58 to reflect third requested…
xnealcarson Nov 2, 2025
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
157 changes: 112 additions & 45 deletions github-actions/activity-trigger/post-to-skills-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const checkTeamMembership = require('../utils/check-team-membership');
const statusFieldIds = require('../utils/_data/status-field-ids');
const mutateIssueStatus = require('../utils/mutate-issue-status');
const { lookupSkillsDirectory, updateSkillsDirectory } = require('../utils/skills-directory');

// `complexity0` refers `Complexity: Prework` label
const SKILLS_LABEL = retrieveLabelDirectory("complexity0");
Expand Down Expand Up @@ -33,71 +34,137 @@
console.log(`eventActor is undefined (likely a bot). Cannot post message...`);
return;
}

// Get eventActor's Skills Issue number, nodeId, current statusId (all null if no Skills Issue found)
const skillsInfo = await querySkillsIssue(github, context, eventActor, SKILLS_LABEL);

// Step 1: Try local directory lookup first
let skillsInfo = lookupSkillsDirectory(eventActor);

if (!skillsInfo) {
console.log(`No cached Skills Issue found for ${eventActor}, querying GitHub...`);

// Step 2: Fallback to GitHub API
skillsInfo = await querySkillsIssue(github, context, eventActor, SKILLS_LABEL);

// Step 3: Save result to local directory if found
if (skillsInfo && skillsInfo.issueNum) {
updateSkillsDirectory(eventActor, skillsInfo);
}
}

// Get eventActor's Skills Issue number, nodeId, current statusId (all null if no Skills Issue found)
const skillsIssueNum = skillsInfo.issueNum;
const skillsIssueNodeId = skillsInfo.issueId;
const skillsStatusId = skillsInfo.statusId;
const isArchived = skillsInfo.isArchived;

const skillsStatusId = skillsInfo?.statusId || 'unknown';
const isArchived = skillsInfo?.isArchived || false;
const commentFoundId = skillsInfo?.commentId || null; // not used currently

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable commentFoundId.

console.log(`skillsIssueNum: ${skillsIssueNum}, skillsIssueNodeId: ${skillsIssueNodeId}, skillsStatusId: ${skillsStatusId}, isArchived: ${isArchived}`); // only for debugging

// Return immediately if Skills Issue not found
if (!skillsIssueNum) {
console.log(` ⮡ Did not find Skills Issue for ${eventActor}. Cannot post message.`);
return;
}
console.log(` ⮡ Found Skills Issue for ${eventActor}: #${skillsIssueNum}`);

// Get all comments from the Skills Issue
let commentData;
try {
// https://docs.github.com/en/rest/issues/comments?apiVersion=2022-11-28#list-issue-comments
commentData = await github.request('GET /repos/{owner}/{repo}/issues/{issue_number}/comments', {
owner,
repo,
per_page: 100,
issue_number: skillsIssueNum,
});
} catch (err) {
console.error(` ⮡ GET comments failed for issue #${skillsIssueNum}:`, err);
return;
}
let commentIdToUse = commentIdCached;
let commentFound = null;

// Try cached comment ID first
if (commentIdCached) {
console.log(` ⮡ Found cached comment ID for ${eventActor}: ${commentIdCached}`);
try {
const { data: cachedComment } = await github.request(
'GET /repos/{owner}/{repo}/issues/comments/{comment_id}',
{
owner,
repo,
comment_id: commentIdCached,
}
);

// Find the comment that includes the MARKER text and append message
const commentFound = commentData.data.find(comment => comment.body.includes(MARKER));
if (cachedComment && cachedComment.body.includes(MARKER)) {
const updatedBody = `${cachedComment.body}\n${message}`;
await github.request('PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}', {
owner,
repo,
comment_id: commentIdCached,
body: updatedBody,
});
console.log(` ⮡ Updated cached comment #${commentIdCached}`);
return; // Done
}
} catch (err) {
console.warn(` ⮡ Cached comment invalid or not found. Falling back to search.`, err);
commentIdToUse = null; // Force fallback path
}
}

if (commentFound) {
console.log(` ⮡ Found comment with MARKER...`);
const comment_id = commentFound.id;
const originalBody = commentFound.body;
const updatedBody = `${originalBody}\n${message}`;
// Fallback — search for MARKER or create new comment
if (!commentIdToUse) {
console.log(` ⮡ Searching for activity comment marker...`);
let commentData;
try {
// https://docs.github.com/en/rest/issues/comments?apiVersion=2022-11-28#update-an-issue-comment
await github.request('PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}', {
owner,
repo,
comment_id,
body: updatedBody
});
console.log(` ⮡ Entry posted to Skills Issue #${skillsIssueNum}`);
commentData = await github.request(
'GET /repos/{owner}/{repo}/issues/{issue_number}/comments',
{
owner,
repo,
per_page: 100,
issue_number: skillsIssueNum,
}
);
} catch (err) {
console.error(` ⮡ Something went wrong posting entry to #${skillsIssueNum}:`, err);
console.error(` ⮡ GET comments failed for issue #${skillsIssueNum}:`, err);
return;
}

} else {
console.log(` ⮡ MARKER not found, creating new comment entry with MARKER...`);
const body = `${MARKER}\n## Activity Log: ${eventActor}\n### Repo: https://github.com/hackforla/website\n\n##### ⚠ Important note: The bot updates this comment automatically - do not edit\n\n${message}`;
const commentPosted = await postComment(skillsIssueNum, body, github, context);
if (commentPosted) {
console.log(` ⮡ Entry posted to Skills Issue #${skillsIssueNum}`);

commentFound = commentData.data.find((comment) => comment.body.includes(MARKER));

if (commentFound) {
console.log(` ⮡ Found comment with MARKER...`);
const comment_id = commentFound.id;
const originalBody = commentFound.body;
const updatedBody = `${originalBody}\n${message}`;
try {
await github.request('PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}', {
owner,
repo,
comment_id,
body: updatedBody,
});
console.log(` ⮡ Entry posted to Skills Issue #${skillsIssueNum}`);
// Cache this comment ID
updateSkillsDirectory(eventActor, { commentId: comment_id });
} catch (err) {
console.error(` ⮡ Something went wrong posting entry to #${skillsIssueNum}:`, err);
}
} else {
console.log(` ⮡ MARKER not found, creating new comment entry with MARKER...`);
const body = `${MARKER}\n## Activity Log: ${eventActor}\n### Repo: https://github.com/hackforla/website\n\n##### ⚠ Important note: The bot updates this comment automatically - do not edit\n\n${message}`;
try {
const { data: newComment } = await github.request(
'POST /repos/{owner}/{repo}/issues/{issue_number}/comments',
{
owner,
repo,
issue_number: skillsIssueNum,
body,
}
);
console.log(` ⮡ Entry posted to Skills Issue #${skillsIssueNum}`);
// Cache new comment ID
updateSkillsDirectory(eventActor, { commentId: newComment.id });
} catch (err) {
console.error(` ⮡ Failed to create new comment for issue #${skillsIssueNum}:`, err);
}
}
}

// Only proceed if Skills Issue message does not include: 'closed', 'assigned', or isArchived
if (!(message.includes('closed') || message.includes('assigned') || isArchived)) {

// If eventActor is team member, open issue and move to "In progress"
const isActiveMember = await checkTeamMembership(github, context, eventActor, TEAM);
const isActiveMember = await checkTeamMembership(github, context, eventActor, TEAM);

if (isActiveMember) {
try {
Expand All @@ -121,4 +188,4 @@

}

module.exports = postToSkillsIssue;
module.exports = postToSkillsIssue;
Loading