File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ This is designed to be used in conjunction with other actions that output to a f
77Especially if that output can be formatted as [ GitHub flavoured Markdown] ( https://help.github.com/en/articles/basic-writing-and-formatting-syntax ) .
88This action will create an issue if a file exists at a specified path.
99The content of the issue will be taken from the file as-is.
10+ If project variables are specified, a card will be added to a project.
1011If the file does not exist the action exits silently.
1112
1213## Usage
@@ -19,6 +20,8 @@ If the file does not exist the action exits silently.
1920 ISSUE_TITLE : An example issue
2021 ISSUE_CONTENT_FILEPATH : ./example-content/output.md
2122 ISSUE_LABELS : report, automated issue
23+ PROJECT_NAME : Example Project
24+ PROJECT_COLUMN_NAME : To do
2225` ` `
2326
2427#### Environment variables
@@ -27,6 +30,8 @@ If the file does not exist the action exits silently.
2730- ` ISSUE_CONTENT_FILEPATH` (**required**) - The file path to the issue content
2831- ` ISSUE_LABELS` - A comma separated list of labels to apply
2932- ` ISSUE_ASSIGNEES` - A comma separated list of assignees (GitHub usernames)
33+ - ` PROJECT_NAME` - The name of a project to add a project card to (Requires `PROJECT_COLUMN_NAME`)
34+ - ` PROJECT_COLUMN_NAME` - The name of the project column to add the card to
3035
3136# # Actions that pair with this action
3237
Original file line number Diff line number Diff line change 1313# Fetch optional environment variables
1414issue_labels = os .environ .get ('ISSUE_LABELS' )
1515issue_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
1820if not Path (issue_content_path ).is_file ():
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 ))
You can’t perform that action at this time.
0 commit comments