Skip to content

Commit 3c57345

Browse files
committed
Refactor issue creation to build JSON payloads for issue and comment, enhancing clarity and maintainability
1 parent ad37502 commit 3c57345

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

‎.github/workflows/weekly-upstream-sync.yml‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,31 +108,38 @@ jobs:
108108
# Read custom instructions from external file
109109
CUSTOM_INSTRUCTIONS=$(cat .github/prompts/coding-agent-merge-instructions.md)
110110
111-
# Create the issue (without assignee to avoid permission issues)
112-
jq -n \
111+
# Build the issue JSON payload
112+
ISSUE_PAYLOAD=$(jq -n \
113113
--arg title "Upstream sync: ${COMMIT_COUNT} new commits (${DATE})" \
114114
--arg body "$BODY" \
115115
'{
116116
title: $title,
117117
body: $body,
118118
labels: ["upstream-sync"]
119-
}' | gh api \
119+
}')
120+
121+
# Create the issue
122+
ISSUE_NUMBER=$(echo "$ISSUE_PAYLOAD" | \
123+
gh api \
120124
--method POST \
121125
-H "Accept: application/vnd.github+json" \
122126
-H "X-GitHub-Api-Version: 2022-11-28" \
123127
"/repos/${REPO}/issues" \
124128
--input - \
125-
--jq '.number' > /tmp/issue_number.txt
129+
--jq '.number')
126130
127-
ISSUE_NUMBER=$(cat /tmp/issue_number.txt)
128131
echo "Created issue #${ISSUE_NUMBER}"
129132
130-
# Trigger Copilot by @mentioning it with custom instructions
131-
jq -n \
133+
# Build the comment JSON payload to trigger Copilot
134+
COMMENT_PAYLOAD=$(jq -n \
132135
--arg instructions "$CUSTOM_INSTRUCTIONS" \
133136
'{
134137
body: ("@copilot\n\n" + $instructions)
135-
}' | gh api \
138+
}')
139+
140+
# Post the comment to assign Copilot
141+
echo "$COMMENT_PAYLOAD" | \
142+
gh api \
136143
--method POST \
137144
-H "Accept: application/vnd.github+json" \
138145
-H "X-GitHub-Api-Version: 2022-11-28" \

0 commit comments

Comments
 (0)