Skip to content

Commit 667945e

Browse files
committed
Fix JSON generation in workflow
Use jq to properly build request JSON and handle prompt escaping.
1 parent 3e17d5b commit 667945e

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

.github/workflows/generate-site.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,28 @@ jobs:
3030
- name: Generate site with Claude API
3131
env:
3232
ANTHROPIC_API_KEY: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
33+
PROMPT_CONTENT: ${{ steps.prompt.outputs.content }}
3334
run: |
34-
# Build the prompt
35-
cat > request.json <<'JSONEOF'
36-
{
37-
"model": "claude-sonnet-4-20250514",
38-
"max_tokens": 8192,
39-
"messages": [
40-
{
41-
"role": "user",
42-
"content": "You are a web developer creating a GitHub Pages site.\n\nHere are the requirements:\n\n${{ steps.prompt.outputs.content }}\n\nPlease generate a complete, production-ready index.html file. Output ONLY the HTML code, no explanations or markdown code blocks."
43-
}
44-
]
45-
}
46-
JSONEOF
35+
# Build the JSON request with jq to handle escaping
36+
jq -n \
37+
--arg model "claude-sonnet-4-20250514" \
38+
--arg prompt "You are a web developer creating a GitHub Pages site.
39+
40+
Here are the requirements:
41+
42+
$PROMPT_CONTENT
43+
44+
Please generate a complete, production-ready index.html file following all requirements. Output ONLY the HTML code, no explanations or markdown code blocks." \
45+
'{
46+
model: $model,
47+
max_tokens: 8192,
48+
messages: [
49+
{
50+
role: "user",
51+
content: $prompt
52+
}
53+
]
54+
}' > request.json
4755

4856
# Call Claude API
4957
RESPONSE=$(curl -s https://api.anthropic.com/v1/messages \

0 commit comments

Comments
 (0)