1616# See the License for the specific language governing permissions and
1717# limitations under the License.
1818
19- # Script to create a sub-issue for linting failures
19+ # Script to create a sub-issue.
2020#
21- # Usage: ./create_lint_sub_issue .sh <workflow-url > <lint-type > <parent-issue-number>
21+ # Usage: ./create_sub_issue .sh <issue-title > <body-file > <parent-issue-number>
2222#
2323# Arguments:
2424#
25- # workflow-url URL of the workflow run .
26- # lint-type Type of linting failure .
25+ # issue-title Title for the new sub-issue .
26+ # body-file Path to the file containing the issue body .
2727# parent-issue-number Number of the parent issue.
28- # error-log-file Path to the error log file.
29- #
3028#
3129# Environment variables:
3230#
@@ -41,10 +39,9 @@ set -o pipefail
4139# VARIABLES #
4240
4341# Assign command line arguments to variables:
44- workflow_url =" $1 "
45- lint_type =" $2 "
42+ issue_title =" $1 "
43+ body_file =" $2 "
4644parent_issue_number=" $3 "
47- error_log_file=" $4 "
4845
4946# Repository information:
5047owner=" stdlib-js"
@@ -57,28 +54,12 @@ if [ -z "$github_token" ]; then
5754 exit 1
5855fi
5956
60- # Read and format the error log
61- if [ ! -f " $error_log_file " ]; then
62- echo -e " Error log file not found: ${error_log_file } "
57+ # Read and validate the body file:
58+ if [ ! -f " $body_file " ]; then
59+ echo -e " ERROR: Body file not found: ${body_file } "
6360 exit 1
6461fi
65- error_log_content=$( cat " $error_log_file " )
66-
67- # Create issue body with formatted error log
68- issue_body=" ## ${lint_type} Linting Failures
69-
70- Linting failures were detected in the automated lint workflow run.
71-
72- ### Workflow Details
73- - Run: ${workflow_url}
74- - Type: ${lint_type} Linting
75- - Date: $( date -u +" %Y-%m-%d %H:%M:%S UTC" )
76-
77- ### Error Details
78- \`\`\`
79- ${error_log_content}
80- \`\`\`
81- "
62+ issue_body=$( cat " $body_file " )
8263
8364# FUNCTIONS #
8465
@@ -130,7 +111,7 @@ create_child_issue() {
130111 "query": "mutation CreateIssue(\$ repositoryId: ID!, \$ title: String!, \$ body: String!) { createIssue(input: {repositoryId: \$ repositoryId, title: \$ title, body: \$ body}) { issue { id number } } }",
131112 "variables": {
132113 "repositoryId": "${repo_id} ",
133- "title": "Fix ${lint_type} lint errors ",
114+ "title": "${issue_title} ",
134115 "body": $( echo " $issue_body " | jq -R -s ' .' )
135116 }
136117}
@@ -194,7 +175,7 @@ main() {
194175 exit 1
195176 fi
196177
197- echo " Creating child issue for ${lint_type} lint failures ..."
178+ echo " Creating child issue..."
198179 child_issue_response=$( create_child_issue " $repo_id " " $issue_body " )
199180
200181 child_issue_id=$( echo " $child_issue_response " | jq -r ' .data.createIssue.issue.id' )
0 commit comments