Skip to content

Commit 210d7bd

Browse files
authored
Update integration-doc-generator.yml
1 parent 26651d5 commit 210d7bd

File tree

1 file changed

+52
-45
lines changed

1 file changed

+52
-45
lines changed

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

Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,22 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
# 1. Checkout the docs repo on the target branch
17+
# Step 1: Checkout appsmith-docs repo
1818
- name: Checkout appsmith-docs
1919
uses: actions/checkout@v4
2020
with:
2121
token: ${{ secrets.REPO_ACCESS_TOKEN }}
2222
ref: ${{ github.event.inputs.target_branch }}
2323
fetch-depth: 0
2424

25-
# 2. Checkout the integration-resources repo
26-
- name: Checkout integration-resources
27-
uses: actions/checkout@v4
28-
with:
29-
repository: appsmithorg/integration-resources
30-
token: ${{ secrets.REPO_ACCESS_TOKEN }}
31-
ref: main
32-
path: integration-resources
33-
fetch-depth: 1
34-
35-
# 3. Hardcode the two files to process
25+
# Step 2: Set local files to process
3626
- name: Set files to process manually
3727
run: |
3828
echo "intercom_uqi_config.json" > files_to_process.txt
3929
echo "sharepoint_uqi_config.json" >> files_to_process.txt
4030
cat files_to_process.txt
4131
42-
# 4. Generate docs via OpenAI
32+
# Step 3: Generate Markdown docs using OpenAI
4333
- name: Generate docs with OpenAI
4434
env:
4535
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
@@ -49,45 +39,62 @@ jobs:
4939
while IFS= read -r FILE_NAME; do
5040
echo "⏳ Processing $FILE_NAME"
5141
52-
# Build and URL-encode the full relative path
53-
REL="Generic UQI Creation/uqi_configs/${FILE_NAME}"
54-
ENC=$(echo "$REL" | sed 's/ /%20/g')
55-
RAW_URL="https://raw.githubusercontent.com/appsmithorg/integration-resources/main/$ENC"
56-
echo "Fetching $RAW_URL"
57-
curl -fsSL "$RAW_URL" -o input.json || {
58-
echo "❌ Failed to fetch $FILE_NAME"
42+
INPUT_PATH=".github/resources/integration-configs/$FILE_NAME"
43+
if [ ! -f "$INPUT_PATH" ]; then
44+
echo "❌ File not found: $INPUT_PATH"
5945
exit 1
60-
}
46+
fi
6147
6248
# Step 1: extract integration details
63-
SYS1=$(< .github/prompts/extract_prompt.txt)
64-
USR1=$(< input.json)
65-
PAY1=$(jq -nc --arg sys "$SYS1" --arg usr "$USR1" \
66-
'{model:"gpt-4-1106-preview",messages:[{role:"system",content:$sys},{role:"user",content:$usr}],max_tokens:2000,temperature:0}')
67-
RES1=$(curl -s -H "Authorization: Bearer $OPENAI_API_KEY" \
68-
-H "Content-Type: application/json" \
69-
-d "$PAY1" \
70-
https://api.openai.com/v1/chat/completions)
71-
EXTRACTED=$(echo "$RES1" | jq -r '.choices[0].message.content')
49+
SYSTEM_PROMPT_1=$(cat .github/prompts/extract_prompt.txt)
50+
USER_INPUT_1=$(cat "$INPUT_PATH")
51+
52+
PAYLOAD_1=$(jq -nc \
53+
--arg sys "$SYSTEM_PROMPT_1" \
54+
--arg usr "$USER_INPUT_1" \
55+
'{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 \
58+
-H "Authorization: Bearer $OPENAI_API_KEY" \
59+
-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
67+
68+
EXTRACTED_CONTENT=$(echo "$RESPONSE_1" | jq -r '.choices[0].message.content')
7269
7370
# Step 2: generate markdown
74-
SYS2=$(< .github/prompts/generate_prompt.txt)
75-
PAY2=$(jq -nc --arg sys "$SYS2" --arg usr "$EXTRACTED" \
76-
'{model:"gpt-4-1106-preview",messages:[{role:"system",content:$sys},{role:"user",content:$usr}],max_tokens:4000,temperature:0.3}')
77-
RES2=$(curl -s -H "Authorization: Bearer $OPENAI_API_KEY" \
78-
-H "Content-Type: application/json" \
79-
-d "$PAY2" \
80-
https://api.openai.com/v1/chat/completions)
81-
MD=$(echo "$RES2" | jq -r '.choices[0].message.content')
82-
83-
# Save markdown
84-
NAME=$(basename "$FILE_NAME" "_uqi_config.json" | tr '[:upper:]' '[:lower:]')
85-
OUT="website/docs/connect-data/reference/${NAME}.md"
86-
echo "$MD" > "$OUT"
87-
echo "✅ Wrote $OUT"
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" \
76+
'{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 \
79+
-H "Authorization: Bearer $OPENAI_API_KEY" \
80+
-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
88+
89+
FINAL_MD=$(echo "$RESPONSE_2" | jq -r '.choices[0].message.content')
90+
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"
8895
done < files_to_process.txt
8996
90-
# 5. Commit & open PR
97+
# Step 4: Create a PR with generated docs
9198
- name: Commit & Create Pull Request
9299
uses: peter-evans/create-pull-request@v6
93100
with:

0 commit comments

Comments
 (0)