Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 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
77ed1a1
Merge branch 'hackforla:gh-pages' into enhance-gha-skillsactivity-8316
xnealcarson Nov 11, 2025
2716d2b
Merge branch 'hackforla:gh-pages' into enhance-gha-skillsactivity-8316
xnealcarson Nov 14, 2025
d16a0a8
Update skills-directory.js updated lookupSkillsDirectory and updateSk…
xnealcarson Nov 14, 2025
5e1f55f
Merge branch 'hackforla:gh-pages' into enhance-gha-skillsactivity-8316
xnealcarson Nov 22, 2025
9e6524d
Merge branch 'hackforla:gh-pages' into enhance-gha-skillsactivity-8316
xnealcarson Nov 24, 2025
33924db
Update skills-directory.js
xnealcarson Nov 24, 2025
7383d6c
Update post-to-skills-issue.js
xnealcarson Nov 24, 2025
a57eac9
Merge branch 'hackforla:gh-pages' into enhance-gha-skillsactivity-8316
xnealcarson Dec 6, 2025
0814cd4
Update activity-trigger.yml line 25 for testing changes made to PR #8370
xnealcarson Dec 6, 2025
d5450d5
Update post-to-skills-issue.js
xnealcarson Dec 6, 2025
9e5a8be
Update post-to-skills-issue.js
xnealcarson Dec 6, 2025
fcfdafc
Merge branch 'hackforla:gh-pages' into enhance-gha-skillsactivity-8316
xnealcarson Dec 9, 2025
58074a5
Update post-to-skills-issue.js
xnealcarson Dec 10, 2025
4ba5279
Update post-to-skills-issue.js
xnealcarson Dec 12, 2025
b74bae2
Merge branch 'hackforla:gh-pages' into enhance-gha-skillsactivity-8316
xnealcarson Dec 12, 2025
fa4e10b
Update post-to-skills-issue.js
xnealcarson Dec 12, 2025
0b632cd
Update skills-directory.js
xnealcarson Dec 12, 2025
d094b96
Merge branch 'hackforla:gh-pages' into enhance-gha-skillsactivity-8316
xnealcarson Dec 16, 2025
c3d296d
Update post-to-skills-issue.js: fixed syntax error for (!skillsInfo) …
xnealcarson Dec 16, 2025
0780650
Update post-to-skills-issue.js: syntax error fix
xnealcarson Dec 16, 2025
ee0d837
Update skills-directory.js: syntax fix for `updateSkillsDirectory` fu…
xnealcarson Dec 16, 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
2 changes: 1 addition & 1 deletion .github/workflows/activity-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ permissions:
jobs:
Gather-Activity-Event-Information:
runs-on: ubuntu-latest
if: github.repository == 'hackforla/website'
if: github.repository == 'xnealcarson/website'
steps:
- uses: actions/checkout@v5

Expand Down
172 changes: 125 additions & 47 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,72 +34,149 @@
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);
const skillsIssueNum = skillsInfo.issueNum;
const skillsIssueNodeId = skillsInfo.issueId;
const skillsStatusId = skillsInfo.statusId;
const isArchived = skillsInfo.isArchived;

// Step 1: Try local directory lookup first
let needsUpdate = false;
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) {
needsUpdate = true

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (98% of all statements in
the enclosing function
have an explicit semicolon).
} else {
console.log(` ⮡ No Skills Issue found for ${eventActor}. Cannot post message.`);
return;
}
}
// Get eventActor's Skills Issue number, nodeId, current statusId (all null if no Skills Issue found)
//const skillsIssueNum = skillsInfo.issueNum;
const skillsIssueNum = 17;
const skillsIssueNodeId = skillsInfo.issueId;
const skillsStatusId = skillsInfo?.statusId || 'unknown';
const isArchived = skillsInfo?.isArchived || false;
const commentIdCached = skillsInfo?.commentId || null; // not used currently

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;

// Find the comment that includes the MARKER text and append message
const commentFound = commentData.data.find(comment => comment.body.includes(MARKER));
// 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,
}
);

if (commentFound) {
console.log(` ⮡ Found comment with MARKER...`);
const comment_id = commentFound.id;
const originalBody = commentFound.body;
const updatedBody = `${originalBody}\n${message}`;
if (cachedComment && cachedComment.body.includes(MARKER)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't satisfy this if statement, I think we accidentally skip the fallback (because commendIdToUse is set to commendIdCached, which is non-null if we get here)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment still applies. You could potentially resolve this by adding an else that sets commentIdToUse to null.

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}`);

} else {
commentIdToUse = null;
}
} catch (err) {
console.warn(` ⮡ Cached comment invalid or not found. Falling back to search.`, err);
commentIdToUse = null; // Force fallback path
}
}

// 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(

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable newComment.
'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);
}
}
}
if (needsUpdate) {
console.log(` ⮡ Updating Skills Directory for ${eventActor}...`);
updateSkillsDirectory(eventActor, skillsIssueNum, skillsIssueNodeId, commentIdFound);
};


// 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);
const isActiveMember = true;
if (isActiveMember) {
try {
await github.request('PATCH /repos/{owner}/{repo}/issues/{issue_number}', {
Expand All @@ -121,4 +199,4 @@

}

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