@@ -2,7 +2,7 @@ name: Widget Doc Generator
2
2
3
3
on :
4
4
schedule :
5
- - cron : ' 0 3 * * 1' # Weekly: Monday at 03:00 UTC
5
+ - cron : ' 0 3 * * 1' # Every Monday at 03:00 UTC
6
6
workflow_dispatch :
7
7
inputs :
8
8
target_branch :
@@ -24,16 +24,15 @@ jobs:
24
24
token : ${{ secrets.REPO_ACCESS_TOKEN_WIDGETS }}
25
25
ref : ${{ env.TARGET_BRANCH }}
26
26
fetch-depth : 0
27
- persist-credentials : false
28
27
29
- - name : Checkout appsmith repo (release branch)
28
+ - name : Checkout appsmith (release branch)
30
29
uses : actions/checkout@v4
31
30
with :
32
31
repository : appsmithorg/appsmith
33
32
token : ${{ secrets.REPO_ACCESS_TOKEN_WIDGETS }}
34
33
ref : release
35
34
path : appsmith
36
- fetch-depth : 2
35
+ fetch-depth : 0
37
36
38
37
- name : Get changed widget files
39
38
id : changed-files
@@ -42,33 +41,36 @@ jobs:
42
41
path : appsmith/app/client/src/widgets
43
42
since_last_remote_commit : true
44
43
45
- - name : Save list of changed widget files
44
+ - name : Filter widget ` widget/index.tsx` files
46
45
run : |
47
46
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
49
51
if [ ! -s widget_files_to_process.txt ]; then
50
- echo "No widget changes. Exiting."
52
+ echo "No relevant widget changes found . Exiting."
51
53
exit 0
52
54
fi
55
+
53
56
echo "changes_found=true" >> $GITHUB_ENV
54
57
55
- - name : Process widget files with OpenAI
58
+ - name : Generate documentation with OpenAI
56
59
if : env.changes_found == 'true'
57
60
run : |
58
61
mkdir -p website/docs/widgets
59
62
PROCESSED_COUNT=0
60
63
61
64
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"
65
66
66
- cp "$FILE_PATH" widget_input.js
67
+ WIDGET_NAME=$(basename "$(dirname "$(dirname "$FILE_PATH")")")
68
+ cp "$FILE_PATH" widget_input.tsx
67
69
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 )
70
72
71
- # Prompt 1: Extract content
73
+ # Step 1: Extraction
72
74
PAYLOAD1=$(jq -n \
73
75
--arg system "$SYSTEM_PROMPT" \
74
76
--arg user "$USER_CONTENT" \
@@ -88,16 +90,16 @@ jobs:
88
90
-d "$PAYLOAD1")
89
91
90
92
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 "
92
94
echo "$RESPONSE1" | jq .
93
95
continue
94
96
fi
95
97
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
97
99
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)
101
103
102
104
PAYLOAD2=$(jq -n \
103
105
--arg system "$SYSTEM_PROMPT" \
@@ -118,20 +120,20 @@ jobs:
118
120
-d "$PAYLOAD2")
119
121
120
122
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 "
122
124
echo "$RESPONSE2" | jq .
123
125
continue
124
126
fi
125
127
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
127
129
128
130
FINAL_PATH="website/docs/widgets/${WIDGET_NAME}.md"
129
131
mkdir -p "$(dirname "$FINAL_PATH")"
130
- cp generated_widget_doc.md "$FINAL_PATH"
131
-
132
+ cp generated_doc.md "$FINAL_PATH"
132
133
echo "$FILE_PATH" >> scripts/processed_widgets.txt
134
+
133
135
PROCESSED_COUNT=$((PROCESSED_COUNT + 1))
134
- echo "✅ Done: $WIDGET_NAME"
136
+ echo "✅ Generated doc for $WIDGET_NAME"
135
137
136
138
done < widget_files_to_process.txt
137
139
@@ -142,9 +144,9 @@ jobs:
142
144
echo "content_generated=false" >> $GITHUB_ENV
143
145
fi
144
146
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
146
148
147
- - name : Commit and create PR
149
+ - name : Commit and open PR
148
150
if : env.content_generated == 'true'
149
151
uses : peter-evans/create-pull-request@v6
150
152
with :
@@ -153,15 +155,16 @@ jobs:
153
155
commit-message : |
154
156
docs: auto-generated widget documentation
155
157
156
- Generated markdown for modified widget files .
158
+ Generated markdown for updated widgets from `appsmithorg/appsmith` .
157
159
branch : " widgets-update/${{ env.TARGET_BRANCH }}-${{ github.run_id }}"
158
160
base : ${{ env.TARGET_BRANCH }}
159
161
add-paths : |
160
162
website/docs/widgets/
161
163
scripts/processed_widgets.txt
162
164
body : |
163
- 🛠 Auto-generated docs for updated widgets from `appsmithorg/appsmith`.
165
+ 📘 Auto-generated docs for updated widgets from `appsmithorg/appsmith`.
164
166
165
167
**Branch:** `${{ env.TARGET_BRANCH }}`
166
168
**Processed Files:**
167
169
$(cat scripts/processed_widgets.txt | sed 's/^/- /')
170
+
0 commit comments