Skip to content

Commit f6665a4

Browse files
committed
add option to add card to project
1 parent 4f34cc1 commit f6665a4

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

create-issue-from-file.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# Fetch optional environment variables
1414
issue_labels = os.environ.get('ISSUE_LABELS')
1515
issue_assignees = os.environ.get('ISSUE_ASSIGNEES')
16+
project_name = os.environ.get('PROJECT_NAME')
17+
project_column_name = os.environ.get('PROJECT_COLUMN_NAME')
1618

1719
# If the file does not exist there is no issue to create
1820
if not Path(issue_content_path).is_file():
@@ -47,3 +49,31 @@
4749
# Assign issue
4850
print("Assigning issue to assignees")
4951
issue.edit(assignees=assignees_list)
52+
53+
if project_name is not None and project_column_name is not None:
54+
# Locate the project by name
55+
project = None
56+
for project_item in repo.get_projects("all"):
57+
if project_item.name == project_name:
58+
project = project_item
59+
break
60+
61+
if not project:
62+
print("Project not found")
63+
exit(0)
64+
65+
# Locate the column by name
66+
column = None
67+
for column_item in project.get_columns():
68+
if column_item.name == project_column_name:
69+
column = column_item
70+
break
71+
72+
if not column:
73+
print("Project column not found")
74+
exit(0)
75+
76+
# Add the issue to the project
77+
card = column.create_card(content_id=issue.id, content_type="Issue")
78+
print("Added issue %d to project \"%s\" under column \"%s\"" \
79+
% (issue.number, project.name, column.name))

0 commit comments

Comments
 (0)