New Header #6
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
name: Assign Issue to Project | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
assign_to_project: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up GitHub Script | |
id: assign | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const projectName = "Software"; | |
const columnName = "Backlog"; | |
// Fetch the repository projects | |
const projects = await github.rest.projects.listForRepo({ | |
owner: context.repo.owner, | |
repo: context.repo.repo | |
}); | |
const project = projects.data.find(p => p.name === projectName); | |
if (!project) { | |
core.setFailed(`Project '${projectName}' not found`); | |
return; | |
} | |
// Fetch the columns of the project | |
const { data: columns } = await github.projects.listColumns({ | |
project_id: project.id | |
}); | |
const column = columns.find(c => c.name === columnName); | |
if (!column) { | |
core.setFailed(`Column '${columnName}' not found`); | |
return; | |
} | |
// Create a project card for the issue | |
await github.projects.createCard({ | |
column_id: column.id, | |
content_id: context.payload.issue.id, | |
content_type: 'Issue' | |
}); | |
// Set the status and area for the issue (optional, requires labels) | |
await github.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number | |
}); |