Skip to content

Commit 96dbfad

Browse files
mballanceCopilot
andcommitted
Fix shell quoting: use Python to build JSON request payload
The jq single-quoted filter with '\''s caused bash to misparse the surrounding double-quotes in the jq string literals. Use Python instead to build the JSON — no shell quoting issues. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 983d08a commit 96dbfad

1 file changed

Lines changed: 22 additions & 24 deletions

File tree

.github/workflows/fvutils-weekly-report.yaml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -95,32 +95,30 @@ jobs:
9595
env:
9696
GH_TOKEN: ${{ github.token }}
9797
run: |
98-
ACTIVITY=$(cat /tmp/activity.md)
9998
WEEK_END=$(date -u '+%d %b %Y')
10099
101-
# Build the prompt as a JSON payload using jq to handle escaping
102-
jq -n \
103-
--arg activity "$ACTIVITY" \
104-
--arg week_end "$WEEK_END" \
105-
--arg model "$MODEL" \
106-
'{
107-
model: $model,
108-
messages: [{
109-
role: "user",
110-
content: (
111-
"You are a technical writer for an open-source verification tools project.\n\n" +
112-
"Below is raw weekly activity (commits, PRs, issues) from the fvutils GitHub org " +
113-
"for the week ending " + $week_end + ".\n\n" +
114-
$activity + "\n\n" +
115-
"Write a concise weekly news item suitable for the project website. " +
116-
"Include: a short overall summary paragraph, then a per-repo highlights section " +
117-
"using bullet points, and a brief 'What'\''s next' closing line. " +
118-
"Be factual, avoid hype, use past tense for completed work."
119-
)
120-
}],
121-
max_tokens: 600,
122-
temperature: 0.4
123-
}' > /tmp/request.json
100+
# Build the JSON payload with Python to avoid shell quoting issues
101+
python3 - << PYEOF
102+
import json, os
103+
activity = open('/tmp/activity.md').read()
104+
week_end = "$WEEK_END"
105+
model = "$MODEL"
106+
prompt = (
107+
"You are a technical writer for an open-source verification tools project.\n\n"
108+
f"Below is raw weekly activity (commits, PRs, issues) from the fvutils GitHub org "
109+
f"for the week ending {week_end}.\n\n"
110+
+ activity +
111+
"\n\nWrite a concise weekly news item suitable for the project website. "
112+
"Include: a short overall summary paragraph, then a per-repo highlights section "
113+
"using bullet points, and a brief \"What's next\" closing line. "
114+
"Be factual, avoid hype, use past tense for completed work."
115+
)
116+
payload = {"model": model, "messages": [{"role": "user", "content": prompt}],
117+
"max_tokens": 600, "temperature": 0.4}
118+
with open('/tmp/request.json', 'w') as f:
119+
json.dump(payload, f)
120+
print("Request JSON written.")
121+
PYEOF
124122

125123
gh api -X POST "/models/$MODEL/chat/completions" \
126124
--input /tmp/request.json \

0 commit comments

Comments
 (0)