-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -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", | ||
}); |