-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (46 loc) · 1.61 KB
/
add_to_project.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
});