-
-
Notifications
You must be signed in to change notification settings - Fork 862
Write Collected User Activity History to Users' Skills Lists #8258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
t-will-gillis
merged 13 commits into
hackforla:gh-pages
from
t-will-gillis:create-initial-skills-comment
Aug 9, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6220a84
initial
t-will-gillis c51c730
Update first-post-to-skills-issue.js
t-will-gillis f6d12a7
Update first-post-to-skills-issue.js
t-will-gillis d3d990a
Update first-post-to-skills-issue.js
t-will-gillis e17ec09
add logic to post to skills issue
t-will-gillis a4d3a2b
shorten csv for initial
t-will-gillis 2c8e27d
Update first-post-to-skills-issue.js
t-will-gillis f30f662
consolidate files for testing
t-will-gillis 84ca45b
remove test csv
t-will-gillis 0cd2c28
Update first-post-to-skills-issue.js
t-will-gillis 1a7ace8
schedule cron job
t-will-gillis 3088406
Merge branch 'create-initial-skills-comment' of https://github.com/t-…
t-will-gillis 39b5bf4
tweak csv
t-will-gillis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| name: Post Activity History to all Users | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: 30 22 9 8 * | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| Read-CSV: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Parse CSV | ||
| id: parse-csv | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.HACKFORLA_GRAPHQL_TOKEN }} | ||
| script: | | ||
| const script = require('./github-actions/activity-trigger/first-post-to-skills-issue.js') | ||
| return script({g: github, c: context}) |
121 changes: 121 additions & 0 deletions
121
github-actions/activity-trigger/first-post-to-skills-issue.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| // Import modules | ||
| const fs = require('fs'); | ||
|
|
||
| const retrieveSkillsId = require('./retrieve-skills-id'); | ||
| 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'); | ||
|
|
||
| // Global variables | ||
| var github; | ||
| var context; | ||
|
|
||
| /** | ||
| * Function to retrieve Skills Issue and add comments | ||
| * @param {Object} github - GitHub object | ||
| * @param {Object} context - Context object | ||
| * | ||
| */ | ||
| async function firstPostToSkillsIssue({g, c}) { | ||
|
|
||
| github = g; | ||
| context = c; | ||
|
|
||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const team = 'website-write'; | ||
|
|
||
|
|
||
| try { | ||
| const csvPath = 'github-actions/activity-trigger/member_activity_history_bot.csv'; | ||
| const csvContent = fs.readFileSync(csvPath, 'utf-8'); | ||
|
|
||
| // Parse CSV assuming | ||
| const rows = csvContent | ||
| .trim() | ||
| .split('\n') | ||
| .map(line => line.split(',')); | ||
|
|
||
| const processed = processCsvForSkillsIssue(rows); | ||
|
|
||
| console.log(JSON.stringify(processed, null, 2)); // For testing only | ||
|
|
||
| processed.forEach(async entry => { | ||
| let username = entry.username; | ||
| let skillsIssueNum = entry.issueNum; | ||
| let message = entry.postToSkillsIssue; | ||
| const MARKER = '<!-- Skills Issue Activity Record -->'; | ||
|
|
||
| // 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); | ||
|
|
||
| // Check whether eventActor is team member; if so open issue and move to "In progress" | ||
| const isActiveMember = await checkTeamMembership(github, username, team); | ||
|
|
||
| if (isActiveMember) { | ||
| // If isActiveMember, make sure Skills Issue is open, and... | ||
| await github.request('PATCH /repos/{owner}/{repo}/issues/{issueNum}', { | ||
| owner, | ||
| repo, | ||
| issueNum: skillsIssueNum, | ||
| state: "open", | ||
| }); | ||
| // update issue's status to "In progress (actively working)" | ||
| // Needs skillsIssueNodeId first. | ||
| let skillsIssueNodeId = await retrieveSkillsId(github, context, skillsIssueNum); | ||
| let statusValue = statusFieldIds('In_Progress'); | ||
| await mutateIssueStatus(github, context, skillsIssueNodeId, statusValue); | ||
| } | ||
| }); | ||
|
|
||
| } catch (error) { | ||
| console.error('Error processing CSV:', error); | ||
| process.exit(1); | ||
| } | ||
| } | ||
|
|
||
| function processCsvForSkillsIssue(rows) { | ||
|
|
||
| const results = []; | ||
| let currentUser = null; | ||
| let skillsIssueNum = null; | ||
| let postToSkillsIssue = null; | ||
| let collecting = false; | ||
|
|
||
| for (const row of rows) { | ||
| const username = row[0]; | ||
| const issueNum = row[1]; | ||
| const col3 = row[2]; | ||
|
|
||
| if (username !== currentUser) { | ||
| if (collecting && postToSkillsIssue !== null) { | ||
| results.push({ username: currentUser, issueNum: skillsIssueNum, postToSkillsIssue }); | ||
| } | ||
|
|
||
| currentUser = username; | ||
|
|
||
| if (col3 === "SKILLS ISSUE") { | ||
| postToSkillsIssue = ""; | ||
| skillsIssueNum = issueNum; | ||
| collecting = true; | ||
| } else { | ||
| postToSkillsIssue = null; | ||
| collecting = false; | ||
| } | ||
| } else { | ||
| if (collecting) { | ||
| postToSkillsIssue += col3 + "\n"; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (collecting && postToSkillsIssue !== null) { | ||
| results.push({ username: currentUser, issueNum: skillsIssueNum, postToSkillsIssue }); | ||
| } | ||
|
|
||
| return results; | ||
| } | ||
|
|
||
| module.exports = firstPostToSkillsIssue; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.