Skip to content

Commit f8c3f45

Browse files
authored
Update sample-file-trigger.yml
1 parent 6cf7234 commit f8c3f45

File tree

1 file changed

+47
-41
lines changed

1 file changed

+47
-41
lines changed

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

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
echo "Detecting changes..."
2020
git fetch origin main
2121
CHANGED_FILE=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} -- 'website/docs/sample-workflow-tests/' | head -n 1 || true)
22-
22+
2323
if [ -z "$CHANGED_FILE" ]; then
2424
echo "No relevant file found. Exiting."
2525
exit 0
2626
fi
27-
27+
2828
echo "Changed file detected: $CHANGED_FILE"
2929
echo "file_path=$CHANGED_FILE" >> $GITHUB_ENV
3030
@@ -35,61 +35,67 @@ jobs:
3535
CONTENT=$(cat ${{ env.file_path }} | jq -Rs .)
3636
echo "file_content=$CONTENT" >> $GITHUB_ENV
3737
38-
- name: Extract Details from JSON (OpenAI Part 1)
38+
- name: Extract Commands and Properties (OpenAI Part 1)
3939
id: extract_details
4040
run: |
41-
echo "Sending JSON to OpenAI to extract details..."
41+
echo "Sending JSON to OpenAI for extraction..."
42+
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
4259
4360
EXTRACTED=$(curl -s https://api.openai.com/v1/chat/completions \
4461
-H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \
4562
-H "Content-Type: application/json" \
46-
-d '{
47-
"model": "gpt-4o",
48-
"messages": [
49-
{
50-
"role": "system",
51-
"content": "You are a technical extractor. From the following JSON input, extract and list all properties, labels, descriptions, controlTypes, and configProperties clearly in a flat structure."
52-
},
53-
{
54-
"role": "user",
55-
"content": '${{ env.file_content }}'
56-
}
57-
],
58-
"temperature": 0
59-
}' | jq -r '.choices[0].message.content')
60-
61-
echo "$EXTRACTED" > extracted_details.json
63+
--data-binary @extract_prompt.json | jq -r '.choices[0].message.content')
64+
65+
echo "$EXTRACTED" > extracted_details.txt
6266
echo "Extraction completed."
6367
64-
- name: Generate Documentation Text (OpenAI Part 2)
68+
- name: Generate Markdown Documentation (OpenAI Part 2)
6569
id: generate_doc
6670
run: |
67-
echo "Sending extracted details to OpenAI to generate documentation..."
71+
echo "Generating final documentation..."
72+
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+
}')
6887
69-
DETAILS=$(cat extracted_details.json | jq -Rs .)
88+
echo "$GENERATED_PROMPT" > generate_prompt.json
7089
71-
GENERATED_DOC=$(curl -s https://api.openai.com/v1/chat/completions \
90+
FINAL_DOC=$(curl -s https://api.openai.com/v1/chat/completions \
7291
-H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \
7392
-H "Content-Type: application/json" \
74-
-d '{
75-
"model": "gpt-4o",
76-
"messages": [
77-
{
78-
"role": "system",
79-
"content": "You are a documentation generator. Given the extracted details, write a clean, structured Markdown documentation. Create a 'Properties' table listing each property, control type, label, and description."
80-
},
81-
{
82-
"role": "user",
83-
"content": '"$DETAILS"'
84-
}
85-
],
86-
"temperature": 0.3
87-
}' | jq -r '.choices[0].message.content')
88-
89-
echo "$GENERATED_DOC" > generated_doc.md
93+
--data-binary @generate_prompt.json | jq -r '.choices[0].message.content')
94+
95+
echo "$FINAL_DOC" > generated_doc.md
9096
echo "Documentation generated."
9197
92-
- name: Upload generated documentation as artifact
98+
- name: Upload generated documentation
9399
uses: actions/upload-artifact@v4
94100
with:
95101
name: generated-doc

0 commit comments

Comments
 (0)