Skip to content

Create asana-code.json #22

Create asana-code.json

Create asana-code.json #22

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
with:
fetch-depth: 2
- name: Detect newly added file
id: detect_files
run: |
echo "Detecting newly added files in sample-workflow-tests/..."
ADDED_FILE=$(git diff --name-status HEAD~1 HEAD | awk '$1 == "A" && $2 ~ /^website\/docs\/sample-workflow-tests\// { print $2 }' | head -n 1)
if [ -z "$ADDED_FILE" ]; then
echo "No new file added in target folder. Exiting."
exit 0
fi
echo "New file detected: $ADDED_FILE"
echo "file_path=$ADDED_FILE" >> $GITHUB_ENV
- name: Show file name and content
id: show_file
run: |
echo "Reading content of: ${{ env.file_path }}"
echo "File path: ${{ env.file_path }}"
cat "${{ env.file_path }}"
FILE_CONTENT=$(cat "${{ env.file_path }}")
echo "file_content<<EOF" >> $GITHUB_ENV
echo "$FILE_CONTENT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Extract Commands and Properties (OpenAI Part 1)
run: |
echo "Calling OpenAI to extract commands and properties..."
SYSTEM_PROMPT=$(cat .github/prompts/extract_prompt.txt)
USER_CONTENT="${{ env.file_content }}"
PAYLOAD=$(jq -n --arg sys "$SYSTEM_PROMPT" --arg usr "$USER_CONTENT" '{
model: "gpt-4o",
messages: [
{ role: "system", content: $sys },
{ role: "user", content: $usr }
],
temperature: 0
}')
curl -s https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" | jq -r '.choices[0].message.content' > extracted_info.md
echo "✅ Extracted content:"
cat extracted_info.md
- name: Generate Markdown Documentation (OpenAI Part 2)
run: |
echo "Generating final Markdown documentation..."
SYSTEM_PROMPT=$(cat .github/prompts/generate_prompt.txt)
EXTRACTED_CONTENT=$(cat extracted_info.md)
PAYLOAD=$(jq -n --arg sys "$SYSTEM_PROMPT" --arg usr "$EXTRACTED_CONTENT" '{
model: "gpt-4o",
messages: [
{ role: "system", content: $sys },
{ role: "user", content: $usr }
],
temperature: 0.3
}')
curl -s https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" | jq -r '.choices[0].message.content' > generated_doc.md
echo "✅ Generated documentation:"
cat generated_doc.md
- name: Upload documentation artifacts
uses: actions/upload-artifact@v4
with:
name: documentation-files
path: |
extracted_info.md
generated_doc.md