Skip to content

Commit 371f3b8

Browse files
authored
Update generate-file-for-ai.yaml
1 parent f237f2b commit 371f3b8

File tree

1 file changed

+68
-17
lines changed

1 file changed

+68
-17
lines changed
Lines changed: 68 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,82 @@
1-
name: Generate Markdown File and Upload
1+
name: Process Sample Files and Generate Docs
22

33
on:
4-
schedule:
5-
- cron: '0 0 * * 0' # Runs every Sunday at midnight UTC
6-
workflow_dispatch:
4+
push:
5+
paths:
6+
- 'website/docs/sample-workflow-tests/**'
77

88
jobs:
9-
merge-and-upload-markdown:
9+
process_sample_file:
1010
runs-on: ubuntu-latest
1111

1212
steps:
1313
- name: Checkout repository
14-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1515

16-
- name: Merge markdown files
16+
- name: Detect changed files
17+
id: detect_files
1718
run: |
18-
find website/docs \( -name '*.md' -o -name '*.mdx' \) -exec cat {} + > appsmith-docs.md
19+
git fetch origin main
20+
CHANGED_FILE=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} -- 'website/docs/sample-workflow-tests/' | head -n 1 || true)
21+
if [ -z "$CHANGED_FILE" ]; then
22+
echo "No relevant file found. Exiting."
23+
exit 0
24+
fi
25+
echo "Changed file detected: $CHANGED_FILE"
26+
echo "file_path=$CHANGED_FILE" >> $GITHUB_ENV
1927
20-
- name: Check file size
28+
- name: Read file content
29+
id: read_file
2130
run: |
22-
filesize=$(stat -c%s "appsmith-docs.md")
23-
echo "File size: $filesize bytes"
31+
echo "Reading changed file content..."
32+
FILE_CONTENT=$(cat ${{ env.file_path }} | jq -Rs .)
33+
echo "file_content=$FILE_CONTENT" >> $GITHUB_ENV
2434
25-
- name: Upload merged markdown to API
35+
- name: Extract Commands and Properties (OpenAI Part 1)
36+
id: extract_details
2637
run: |
27-
response=$(curl -X POST \
28-
-H "Content-Type: text/markdown" \
29-
--data-binary "@appsmith-docs.md" \
30-
https://hook.eu1.make.com/78ylobuaxpwb4w8k3lbfgmdlwow9d8m5)
31-
echo "Response: $response"
38+
echo "Extracting commands and properties..."
39+
SYSTEM_PROMPT=$(cat .github/prompts/extract_prompt.txt | jq -Rs .)
40+
41+
curl -s https://api.openai.com/v1/chat/completions \
42+
-H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \
43+
-H "Content-Type: application/json" \
44+
-d @- <<EOF | jq -r '.choices[0].message.content' > extracted_info.md
45+
{
46+
"model": "gpt-4o",
47+
"messages": [
48+
{ "role": "system", "content": $SYSTEM_PROMPT },
49+
{ "role": "user", "content": ${{ env.file_content }} }
50+
],
51+
"temperature": 0
52+
}
53+
EOF
54+
55+
- name: Generate Markdown Documentation (OpenAI Part 2)
56+
id: generate_doc
57+
run: |
58+
echo "Generating final Markdown documentation..."
59+
SYSTEM_PROMPT=$(cat .github/prompts/generate_prompt.txt | jq -Rs .)
60+
EXTRACTED_CONTENT=$(cat extracted_info.md | jq -Rs .)
61+
62+
curl -s https://api.openai.com/v1/chat/completions \
63+
-H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \
64+
-H "Content-Type: application/json" \
65+
-d @- <<EOF | jq -r '.choices[0].message.content' > generated_doc.md
66+
{
67+
"model": "gpt-4o",
68+
"messages": [
69+
{ "role": "system", "content": $SYSTEM_PROMPT },
70+
{ "role": "user", "content": $EXTRACTED_CONTENT }
71+
],
72+
"temperature": 0.3
73+
}
74+
EOF
75+
76+
- name: Upload documentation artifacts
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: documentation-files
80+
path: |
81+
extracted_info.md
82+
generated_doc.md

0 commit comments

Comments
 (0)