@@ -2,7 +2,7 @@ name: Widget Doc Generator
22
33on :
44 schedule :
5- - cron : ' 0 3 * * 1' # Weekly: Monday at 03:00 UTC
5+ - cron : ' 0 3 * * 1' # Every Monday at 03:00 UTC
66 workflow_dispatch :
77 inputs :
88 target_branch :
@@ -24,16 +24,15 @@ jobs:
2424 token : ${{ secrets.REPO_ACCESS_TOKEN_WIDGETS }}
2525 ref : ${{ env.TARGET_BRANCH }}
2626 fetch-depth : 0
27- persist-credentials : false
2827
29- - name : Checkout appsmith repo (release branch)
28+ - name : Checkout appsmith (release branch)
3029 uses : actions/checkout@v4
3130 with :
3231 repository : appsmithorg/appsmith
3332 token : ${{ secrets.REPO_ACCESS_TOKEN_WIDGETS }}
3433 ref : release
3534 path : appsmith
36- fetch-depth : 2
35+ fetch-depth : 0
3736
3837 - name : Get changed widget files
3938 id : changed-files
@@ -42,33 +41,36 @@ jobs:
4241 path : appsmith/app/client/src/widgets
4342 since_last_remote_commit : true
4443
45- - name : Save list of changed widget files
44+ - name : Filter widget ` widget/index.tsx` files
4645 run : |
4746 mkdir -p scripts
48- echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' > widget_files_to_process.txt
47+ echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' |
48+ grep '/widget/index.tsx$' > widget_files_to_process.txt
49+
50+ cat widget_files_to_process.txt
4951 if [ ! -s widget_files_to_process.txt ]; then
50- echo "No widget changes. Exiting."
52+ echo "No relevant widget changes found . Exiting."
5153 exit 0
5254 fi
55+
5356 echo "changes_found=true" >> $GITHUB_ENV
5457
55- - name : Process widget files with OpenAI
58+ - name : Generate documentation with OpenAI
5659 if : env.changes_found == 'true'
5760 run : |
5861 mkdir -p website/docs/widgets
5962 PROCESSED_COUNT=0
6063
6164 while IFS= read -r FILE_PATH; do
62- echo "📦 File: $FILE_PATH"
63- FILE_NAME=$(basename "$FILE_PATH")
64- WIDGET_NAME=$(basename "$(dirname "$FILE_PATH")")
65+ echo "📦 Processing $FILE_PATH"
6566
66- cp "$FILE_PATH" widget_input.js
67+ WIDGET_NAME=$(basename "$(dirname "$(dirname "$FILE_PATH")")")
68+ cp "$FILE_PATH" widget_input.tsx
6769
68- SYSTEM_PROMPT=$(cat .github/prompts/extract_prompt_widget.txt || echo "Extract important widget info.")
69- USER_CONTENT=$(cat widget_input.js )
70+ SYSTEM_PROMPT=$(cat .github/prompts/extract_prompt_widget.txt || echo "Extract important widget info from the following code .")
71+ USER_CONTENT=$(cat widget_input.tsx )
7072
71- # Prompt 1: Extract content
73+ # Step 1: Extraction
7274 PAYLOAD1=$(jq -n \
7375 --arg system "$SYSTEM_PROMPT" \
7476 --arg user "$USER_CONTENT" \
@@ -88,16 +90,16 @@ jobs:
8890 -d "$PAYLOAD1")
8991
9092 if echo "$RESPONSE1" | jq -e '.error' > /dev/null; then
91- echo "❌ Error in Prompt 1 "
93+ echo "❌ OpenAI error on prompt 1 for $WIDGET_NAME "
9294 echo "$RESPONSE1" | jq .
9395 continue
9496 fi
9597
96- echo "$RESPONSE1" | jq -r '.choices[0].message.content' > extracted_widget_info .md
98+ echo "$RESPONSE1" | jq -r '.choices[0].message.content' > extracted_info .md
9799
98- # Prompt 2: Generate markdown
99- SYSTEM_PROMPT=$(cat .github/prompts/generate_prompt_widget.txt || echo "Generate markdown documentation.")
100- EXTRACTED_CONTENT=$(cat extracted_widget_info .md)
100+ # Step 2: Generate Markdown
101+ SYSTEM_PROMPT=$(cat .github/prompts/generate_prompt_widget.txt || echo "Generate markdown documentation for the widget .")
102+ EXTRACTED_CONTENT=$(cat extracted_info .md)
101103
102104 PAYLOAD2=$(jq -n \
103105 --arg system "$SYSTEM_PROMPT" \
@@ -118,20 +120,20 @@ jobs:
118120 -d "$PAYLOAD2")
119121
120122 if echo "$RESPONSE2" | jq -e '.error' > /dev/null; then
121- echo "❌ Error in Prompt 2 "
123+ echo "❌ OpenAI error on prompt 2 for $WIDGET_NAME "
122124 echo "$RESPONSE2" | jq .
123125 continue
124126 fi
125127
126- echo "$RESPONSE2" | jq -r '.choices[0].message.content' > generated_widget_doc .md
128+ echo "$RESPONSE2" | jq -r '.choices[0].message.content' > generated_doc .md
127129
128130 FINAL_PATH="website/docs/widgets/${WIDGET_NAME}.md"
129131 mkdir -p "$(dirname "$FINAL_PATH")"
130- cp generated_widget_doc.md "$FINAL_PATH"
131-
132+ cp generated_doc.md "$FINAL_PATH"
132133 echo "$FILE_PATH" >> scripts/processed_widgets.txt
134+
133135 PROCESSED_COUNT=$((PROCESSED_COUNT + 1))
134- echo "✅ Done: $WIDGET_NAME"
136+ echo "✅ Generated doc for $WIDGET_NAME"
135137
136138 done < widget_files_to_process.txt
137139
@@ -142,9 +144,9 @@ jobs:
142144 echo "content_generated=false" >> $GITHUB_ENV
143145 fi
144146
145- rm -f widget_input.js extracted_widget_info .md generated_widget_doc .md
147+ rm -f widget_input.tsx extracted_info .md generated_doc .md
146148
147- - name : Commit and create PR
149+ - name : Commit and open PR
148150 if : env.content_generated == 'true'
149151 uses : peter-evans/create-pull-request@v6
150152 with :
@@ -153,15 +155,16 @@ jobs:
153155 commit-message : |
154156 docs: auto-generated widget documentation
155157
156- Generated markdown for modified widget files .
158+ Generated markdown for updated widgets from `appsmithorg/appsmith` .
157159 branch : " widgets-update/${{ env.TARGET_BRANCH }}-${{ github.run_id }}"
158160 base : ${{ env.TARGET_BRANCH }}
159161 add-paths : |
160162 website/docs/widgets/
161163 scripts/processed_widgets.txt
162164 body : |
163- 🛠 Auto-generated docs for updated widgets from `appsmithorg/appsmith`.
165+ 📘 Auto-generated docs for updated widgets from `appsmithorg/appsmith`.
164166
165167 **Branch:** `${{ env.TARGET_BRANCH }}`
166168 **Processed Files:**
167169 $(cat scripts/processed_widgets.txt | sed 's/^/- /')
170+
0 commit comments