Skip to content

Update generate-file-for-ai.yaml #13

Update generate-file-for-ai.yaml

Update generate-file-for-ai.yaml #13

name: Process Sample Files and Generate Docs
on:
push:
paths:
- 'website/docs/sample-workflow-tests/**'
jobs:
process_sample_file:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Detect changed files
id: detect_files
run: |
echo "Detecting changes..."
git fetch origin main
CHANGED_FILE=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} -- 'website/docs/sample-workflow-tests/' | head -n 1 || true)
if [ -z "$CHANGED_FILE" ]; then
echo "No relevant file found. Exiting."
exit 0
fi
echo "Changed file detected: $CHANGED_FILE"
echo "file_path=$CHANGED_FILE" >> $GITHUB_ENV
- name: Read file content
id: read_file
run: |
echo "Reading file content..."
FILE_CONTENT=$(cat ${{ env.file_path }} | jq -Rs .)
echo "file_content=$FILE_CONTENT" >> $GITHUB_ENV
- name: Extract Commands and Properties (OpenAI Part 1)
id: extract_details
run: |
echo "Extracting commands and properties..."
curl -s https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \
-H "Content-Type: application/json" \
-d @- <<EOF | jq -r '.choices[0].message.content' > extracted_info.md
{

Check failure on line 44 in .github/workflows/sample-file-trigger.yml

View workflow run for this annotation

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

Invalid workflow file

You have an error in your yaml syntax on line 44
"model": "gpt-4o",
"messages": [
{
"role": "system",
"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."
},
{
"role": "user",
"content": ${{ env.file_content }}
}
],
"temperature": 0
}
EOF
- name: Generate Markdown Documentation (OpenAI Part 2)
id: generate_doc
run: |
echo "Generating final Markdown documentation..."
EXTRACTED_CONTENT=$(cat extracted_info.md | jq -Rs .)
curl -s https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \
-H "Content-Type: application/json" \
-d @- <<EOF | jq -r '.choices[0].message.content' > generated_doc.md
{
"model": "gpt-4o",
"messages": [
{
"role": "system",
"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\nUse:\n- Strict Markdown (#, ##, ### headings)\n- <dd> tags for properties\n- Example sections inside fenced code blocks\n- No bullet points or extra JSON\n- Write full sentences, professional tone."
},
{
"role": "user",
"content": $EXTRACTED_CONTENT
}
],
"temperature": 0.3
}
EOF
- name: Upload generated documentation
uses: actions/upload-artifact@v4
with:
name: documentation-files
path: |
extracted_info.md
generated_doc.md