Skip to content

Commit

Permalink
feat: updating auto-assign.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
DhairyaMajmudar committed Jul 27, 2024
1 parent 116aa88 commit a80ce90
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions .github/workflows/auto-assign.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,64 @@ jobs:
const comment = context.payload.comment;
const issue = context.issue;
const owner = "keyshade-xyz";
const repo = "keyshade"
const repo = "keyshade";
async function updateProjectStatus(issueNumber) {
const projectsResponse = await github.rest.projects.listForRepo({
owner,
repo,
per_page: 100,
});
for (const project of projectsResponse.data) {
const columnsResponse = await github.rest.projects.listColumns({
project_id: project.id,
per_page: 100,
});
const inProgressColumn = columnsResponse.data.find(column => column.name === "In Progress");
if (!inProgressColumn) continue;
const cardsResponse = await github.rest.projects.listCards({
column_id: inProgressColumn.id,
per_page: 100,
});
const issueCardExists = cardsResponse.data.some(card => card.content_id === issueNumber && card.content_type === "Issue");
if (!issueCardExists) {
await github.rest.projects.createCard({
column_id: inProgressColumn.id,
content_id: issueNumber,
content_type: "Issue",
});
}
}
}
if (comment.body.startsWith('/attempt')) {
if (!issue.assignee) {
await github.rest.issues.addAssignees({
owner,
repo,
issue_number: issue.number,
assignees: [comment.user.login]
assignees: [comment.user.login],
});
await github.rest.issues.createComment({
owner,
repo,
issue_number: issue.number,
body: `Assigned the issue to @${comment.user.login}!`
body: `Assigned the issue to @${comment.user.login}!`,
});
await updateProjectStatus(issue.number);
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number: issue.number,
body: 'This issue is already assigned. Tag a maintainer if you need to take over.'
body: 'This issue is already assigned. Tag a maintainer if you need to take over.',
});
}
}

0 comments on commit a80ce90

Please sign in to comment.