Skip to content

Commit 1b1069d

Browse files
authored
Update integration-doc-generator.yml
1 parent a5f5594 commit 1b1069d

File tree

1 file changed

+86
-68
lines changed

1 file changed

+86
-68
lines changed

.github/workflows/integration-doc-generator.yml

Lines changed: 86 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,112 +2,130 @@ name: Integration Doc Generator
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
target_branch:
7-
description: 'Branch in appsmith-docs to create PR against'
8-
required: true
9-
default: 'main'
10-
type: string
5+
schedule:
6+
- cron: '30 20 * * *' # 2:00 AM IST every night (20:30 UTC)
117

128
jobs:
139
generate_docs:
1410
runs-on: ubuntu-latest
1511

1612
steps:
17-
# Step 1: Checkout appsmith-docs repo
13+
# 1. Checkout appsmith-docs (target)
1814
- name: Checkout appsmith-docs
1915
uses: actions/checkout@v4
2016
with:
2117
token: ${{ secrets.REPO_ACCESS_TOKEN }}
22-
ref: ${{ github.event.inputs.target_branch }}
18+
ref: main
2319
fetch-depth: 0
2420

25-
# Step 2: Set local files to process
26-
- name: Set files to process manually
21+
# 2. Checkout integration-resources (source)
22+
- name: Checkout integration-resources
23+
uses: actions/checkout@v4
24+
with:
25+
repository: appsmithorg/integration-resources
26+
token: ${{ secrets.REPO_ACCESS_TOKEN }}
27+
ref: main
28+
path: integration-resources
29+
fetch-depth: 20
30+
31+
# 3. Detect latest committed JSON config
32+
- name: Detect latest committed file
33+
id: detect
34+
run: |
35+
echo "🔍 Finding latest committed integration file..."
36+
cd integration-resources
37+
git log --pretty=format: --name-only -n 20 \
38+
| grep 'Generic UQI Creation/uqi_configs/.*_uqi_config.json' \
39+
| grep -v '^$' \
40+
| head -n 1 \
41+
> ../scripts/candidate_files.txt
42+
cd ..
43+
cat scripts/candidate_files.txt || echo "(no file found)"
44+
45+
# 4. Compare with processed list
46+
- name: Compare with processed_files.txt
47+
id: check
2748
run: |
28-
echo "intercom_uqi_config.json" > files_to_process.txt
29-
echo "sharepoint_uqi_config.json" >> files_to_process.txt
30-
cat files_to_process.txt
49+
mkdir -p scripts
50+
touch scripts/processed_files.txt
51+
52+
echo "" | cat - scripts/candidate_files.txt > tmpfile && mv tmpfile scripts/candidate_files.txt
53+
54+
grep -Fxv -f scripts/processed_files.txt scripts/candidate_files.txt \
55+
> scripts/files_to_process.txt || true
56+
57+
echo "✅ Files to process:"
58+
cat scripts/files_to_process.txt || echo "(none)"
59+
60+
if [ ! -s scripts/files_to_process.txt ]; then
61+
echo "No new files to process. Exiting."
62+
exit 0
63+
fi
3164
32-
# Step 3: Generate Markdown docs using OpenAI
65+
echo "changes_found=true" >> $GITHUB_ENV
66+
67+
# 5. Send to OpenAI + generate markdown
3368
- name: Generate docs with OpenAI
69+
if: env.changes_found == 'true'
3470
env:
3571
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
3672
run: |
3773
mkdir -p website/docs/connect-data/reference
3874
39-
while IFS= read -r FILE_NAME; do
75+
while IFS= read -r FILE_PATH; do
76+
FILE_NAME=$(basename "$FILE_PATH")
4077
echo "⏳ Processing $FILE_NAME"
4178
42-
INPUT_PATH=".github/resources/integration-configs/$FILE_NAME"
43-
if [ ! -f "$INPUT_PATH" ]; then
44-
echo "❌ File not found: $INPUT_PATH"
79+
ENCODED=$(echo "$FILE_PATH" | sed 's/ /%20/g')
80+
FILE_URL="https://raw.githubusercontent.com/appsmithorg/integration-resources/main/${ENCODED}"
81+
echo "🌐 Fetching: $FILE_URL"
82+
curl -fsSL "$FILE_URL" -o input.json || {
83+
echo "❌ Failed to fetch $FILE_NAME"
4584
exit 1
46-
fi
47-
48-
# Step 1: extract integration details
49-
SYSTEM_PROMPT_1=$(cat .github/prompts/extract_prompt.txt)
50-
USER_INPUT_1=$(cat "$INPUT_PATH")
85+
}
5186
52-
PAYLOAD_1=$(jq -nc \
53-
--arg sys "$SYSTEM_PROMPT_1" \
54-
--arg usr "$USER_INPUT_1" \
87+
SYSTEM1=$(cat .github/prompts/extract_prompt.txt)
88+
USER1=$(cat input.json)
89+
PAYLOAD1=$(jq -nc --arg sys "$SYSTEM1" --arg usr "$USER1" \
5590
'{model: "gpt-4-1106-preview", messages: [{"role": "system", "content": $sys}, {"role": "user", "content": $usr}], max_tokens: 2000, temperature: 0}')
56-
57-
RESPONSE_1=$(curl -s https://api.openai.com/v1/chat/completions \
91+
RESPONSE1=$(curl -s https://api.openai.com/v1/chat/completions \
5892
-H "Authorization: Bearer $OPENAI_API_KEY" \
5993
-H "Content-Type: application/json" \
60-
-d "$PAYLOAD_1")
61-
62-
if echo "$RESPONSE_1" | jq -e '.error' > /dev/null; then
63-
echo "❌ OpenAI error on extract"
64-
echo "$RESPONSE_1" | jq .
65-
continue
66-
fi
94+
-d "$PAYLOAD1")
95+
EXTRACTED=$(echo "$RESPONSE1" | jq -r '.choices[0].message.content')
6796
68-
EXTRACTED_CONTENT=$(echo "$RESPONSE_1" | jq -r '.choices[0].message.content')
69-
70-
# Step 2: generate markdown
71-
SYSTEM_PROMPT_2=$(cat .github/prompts/generate_prompt.txt)
72-
73-
PAYLOAD_2=$(jq -nc \
74-
--arg sys "$SYSTEM_PROMPT_2" \
75-
--arg usr "$EXTRACTED_CONTENT" \
97+
SYSTEM2=$(cat .github/prompts/generate_prompt.txt)
98+
PAYLOAD2=$(jq -nc --arg sys "$SYSTEM2" --arg usr "$EXTRACTED" \
7699
'{model: "gpt-4-1106-preview", messages: [{"role": "system", "content": $sys}, {"role": "user", "content": $usr}], max_tokens: 4000, temperature: 0.3}')
77-
78-
RESPONSE_2=$(curl -s https://api.openai.com/v1/chat/completions \
100+
RESPONSE2=$(curl -s https://api.openai.com/v1/chat/completions \
79101
-H "Authorization: Bearer $OPENAI_API_KEY" \
80102
-H "Content-Type: application/json" \
81-
-d "$PAYLOAD_2")
82-
83-
if echo "$RESPONSE_2" | jq -e '.error' > /dev/null; then
84-
echo "❌ OpenAI error on generate"
85-
echo "$RESPONSE_2" | jq .
86-
continue
87-
fi
103+
-d "$PAYLOAD2")
104+
MARKDOWN=$(echo "$RESPONSE2" | jq -r '.choices[0].message.content')
88105
89-
FINAL_MD=$(echo "$RESPONSE_2" | jq -r '.choices[0].message.content')
106+
INTEGRATION_NAME=$(echo "$FILE_NAME" | sed 's/_uqi_config\.json//' | tr '[:upper:]' '[:lower:]')
107+
OUT_PATH="website/docs/connect-data/reference/${INTEGRATION_NAME}.md"
108+
echo "$MARKDOWN" > "$OUT_PATH"
90109
91-
INTEGRATION_NAME=$(basename "$FILE_NAME" "_uqi_config.json" | tr '[:upper:]' '[:lower:]')
92-
OUTPUT_FILE="website/docs/connect-data/reference/${INTEGRATION_NAME}.md"
93-
echo "$FINAL_MD" > "$OUTPUT_FILE"
94-
echo "✅ Wrote $OUTPUT_FILE"
95-
done < files_to_process.txt
110+
echo "$FILE_NAME" >> scripts/processed_files.txt
111+
echo "✅ Wrote: $OUT_PATH"
112+
done < scripts/files_to_process.txt
96113
97-
# Step 4: Create a PR with generated docs
98-
- name: Commit & Create Pull Request
114+
# 6. Commit and raise PR
115+
- name: Commit and Open PR
116+
if: env.changes_found == 'true'
99117
uses: peter-evans/create-pull-request@v6
100118
with:
101119
token: ${{ secrets.REPO_ACCESS_TOKEN }}
102-
title: "docs: update intercom & sharepoint integration docs"
120+
title: "docs: generate new integration doc"
103121
commit-message: |
104-
docs: generated intercom and sharepoint docs
122+
docs: add generated integration doc
105123
106-
Processed: intercom_uqi_config.json, sharepoint_uqi_config.json
107-
branch: "docs-update/${{ github.event.inputs.target_branch }}-${{ github.run_id }}"
108-
base: ${{ github.event.inputs.target_branch }}
124+
Auto-processed newest integration file.
125+
branch: "docs-auto-update/${{ github.run_id }}"
126+
base: main
109127
add-paths: |
110-
website/docs/connect-data/reference/intercom.md
111-
website/docs/connect-data/reference/sharepoint.md
128+
website/docs/connect-data/reference/
129+
scripts/processed_files.txt
112130
body: |
113-
✅ Auto-generated documentation for Intercom and SharePoint integrations.
131+
✅ Auto-generated doc for newly added integration file.

0 commit comments

Comments
 (0)