Skip to content

Commit 3f9ca8a

Browse files
authored
Update sample-file-trigger.yml
1 parent 576a803 commit 3f9ca8a

File tree

1 file changed

+47
-38
lines changed

1 file changed

+47
-38
lines changed

.github/workflows/sample-file-trigger.yml

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,66 +25,75 @@ jobs:
2525
exit 0
2626
fi
2727
28+
echo "Changed file detected: $CHANGED_FILE"
2829
echo "file_path=$CHANGED_FILE" >> $GITHUB_ENV
2930
3031
- name: Read file content
3132
id: read_file
3233
run: |
3334
echo "Reading file content..."
34-
FILE_CONTENT=$(cat ${{ env.file_path }} | jq -Rs .)
35-
echo "file_content=$FILE_CONTENT" >> $GITHUB_ENV
35+
CONTENT=$(cat ${{ env.file_path }} | jq -Rs .)
36+
echo "file_content=$CONTENT" >> $GITHUB_ENV
3637
3738
- name: Extract Commands and Properties (OpenAI Part 1)
3839
id: extract_details
3940
run: |
40-
echo "Extracting commands and properties..."
41+
echo "Sending JSON to OpenAI for extraction..."
4142
42-
RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \
43+
EXTRACT_PROMPT=$(jq -n --arg json_content "${{ env.file_content }}" '{
44+
"model": "gpt-4o",
45+
"messages": [
46+
{
47+
"role": "system",
48+
"content": "You are a technical parser.\n\nObjective:\nGiven the provided JSON, extract all available Commands and their Properties clearly.\n\nOutput Format (Strict Plain Text)\n\nTotal Commands: X\n\nCommand: <Command Name>\nIdentifier: <Command Identifier>\n\nProperties:\n- <Property Name>: <Tooltip Text> (Example: <Placeholder Text>)\n\nImportant:\n- No Markdown formatting.\n- No headings (#, ##, etc.).\n- No <dd> tags.\n- No backticks.\n- Just clean, readable text."
49+
},
50+
{
51+
"role": "user",
52+
"content": $json_content
53+
}
54+
],
55+
"temperature": 0
56+
}')
57+
58+
echo "$EXTRACT_PROMPT" > extract_prompt.json
59+
60+
EXTRACTED=$(curl -s https://api.openai.com/v1/chat/completions \
4361
-H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \
4462
-H "Content-Type: application/json" \
45-
-d '{
46-
"model": "gpt-4o",
47-
"messages": [
48-
{
49-
"role": "system",
50-
"content": "You are a technical parser. Objective: Given the provided JSON, extract all available Commands and their Properties clearly. Output format: Total Commands: X, then for each Command: Identifier, Properties list. Important: No Markdown, no backticks, just clean plain text."
51-
},
52-
{
53-
"role": "user",
54-
"content": '"${{ env.file_content }}"'
55-
}
56-
],
57-
"temperature": 0
58-
}')
59-
60-
echo "$RESPONSE" | jq -r '.choices[0].message.content' > extracted_details.txt
63+
--data-binary @extract_prompt.json | jq -r '.choices[0].message.content')
64+
65+
echo "$EXTRACTED" > extracted_details.txt
66+
echo "Extraction completed."
6167
6268
- name: Generate Markdown Documentation (OpenAI Part 2)
6369
id: generate_doc
6470
run: |
65-
echo "Generating Markdown documentation..."
71+
echo "Generating final documentation..."
6672
67-
EXTRACTED_CONTENT=$(cat extracted_details.txt | jq -Rs .)
73+
GENERATED_PROMPT=$(jq -n --arg extracted_content "$(cat extracted_details.txt)" '{
74+
"model": "gpt-4o",
75+
"messages": [
76+
{
77+
"role": "system",
78+
"content": "You are a professional technical writing assistant.\n\nObjective:\nYou will receive developer-extracted command and property data.\nYour task is to generate strict, professional Markdown integration documentation in a style consistent with platforms like Stripe, Slack, and Google Cloud.\n\n---\n\n# Output Format (Strict Markdown Only)\n\nUse the exact structure:\n\n```markdown\n# <Integration Name> Integration\n\nThis page provides information on how to connect to <Integration Name>. It enables users to perform actions such as <summary like creating events, managing contacts, checking availability>.\n\n## Connect <Integration Name>\n\nExplain how to authenticate and connect to this service.\n\n## Query <Integration Name>\n\nThe following section provides a reference guide describing available commands and their parameters.\n\n---\n\n### <Command Name>\n\n(One sentence summary explaining the purpose of this command.)\n\n#### <Property Name> `data type`\n\n<dd>\n\nWrite 2–4 full sentences in paragraph form.\nExplain what this property is used for, what formats it accepts (e.g., ISO 8601, Unix, array), and what happens if omitted (for optional fields).\nIf it's an ID, also explain where to find it and what format it follows.\n\n*example*:\n```\n<insert example value>\n```\n\n</dd>\n\n---\n\n(Repeat for each command)\n```"
79+
},
80+
{
81+
"role": "user",
82+
"content": $extracted_content
83+
}
84+
],
85+
"temperature": 0.3
86+
}')
87+
88+
echo "$GENERATED_PROMPT" > generate_prompt.json
6889
6990
FINAL_DOC=$(curl -s https://api.openai.com/v1/chat/completions \
7091
-H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \
7192
-H "Content-Type: application/json" \
72-
-d '{
73-
"model": "gpt-4o",
74-
"messages": [
75-
{
76-
"role": "system",
77-
"content": "You are a professional technical writing assistant. Given extracted details, generate strict, professional Markdown integration documentation. Use # headings, <dd> tags, examples inside fenced code blocks, etc. Follow Stripe/Slack/Google Cloud doc style."
78-
},
79-
{
80-
"role": "user",
81-
"content": '"$EXTRACTED_CONTENT"'
82-
}
83-
],
84-
"temperature": 0.3
85-
}')
86-
87-
echo "$FINAL_DOC" | jq -r '.choices[0].message.content' > generated_doc.md
93+
--data-binary @generate_prompt.json | jq -r '.choices[0].message.content')
94+
95+
echo "$FINAL_DOC" > generated_doc.md
96+
echo "Documentation generated."
8897
8998
- name: Upload generated documentation
9099
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)