Skip to content

Commit

Permalink
update: issue processor workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
genie360s committed Dec 11, 2024
1 parent f438453 commit fdee3da
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions .github/workflows/auto-add-to-project.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
name: Add Issue to Project Ushahidi Articles
name: Auto Add To Project Ushahidi Articles

on:
issues:
types:
- labeled
- opened

jobs:
add-to-project:
process-issue:
runs-on: ubuntu-latest
if: contains(github.event.label.name, 'article') && contains(github.event.label.name, 'submission')
steps:
- name: Check for required labels
if: ${{ github.event.label.name == 'article' || github.event.label.name == 'submission' }}
run: echo "The issue has the required labels."
- name: Assign issue to creator
uses: actions/github-script@v6
with:
script: |
const issueCreator = context.payload.issue.user.login;
await github.issues.addAssignees({
...context.repo,
issue_number: context.payload.issue.number,
assignees: [issueCreator]
});
- name: Add to project
- name: Add issue to project
uses: actions/github-script@v6
with:
script: |
const issueNumber = context.payload.issue.number;
const projectId = '26';
const columnId = '<COLUMN_ID>';
const projectName = "Project Ushahidi Articles";
const projects = await github.projects.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
});
const project = projects.data.find(proj => proj.name === projectName);
if (!project) {
throw new Error(`Project "${projectName}" not found`);
}
const columns = await github.projects.listColumns({
project_id: project.id,
});
// Add issue to project column
const column = columns.data[0]; // Add to the first column, adjust as needed
await github.projects.createCard({
column_id: columnId,
content_id: issueNumber,
content_type: 'Issue',
column_id: column.id,
content_id: context.payload.issue.id,
content_type: "Issue",
});

0 comments on commit fdee3da

Please sign in to comment.