Skip to content

Commit ca4a1a7

Browse files
authored
Create poll-and-generate-doc.yml
1 parent a75d6e0 commit ca4a1a7

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Daily Integration Doc Generator
2+
3+
on:
4+
schedule:
5+
- cron: "0 3 * * *" # every day at 3:00 AM UTC
6+
workflow_dispatch:
7+
8+
jobs:
9+
generate_docs:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout appsmith-docs
14+
uses: actions/checkout@v4
15+
16+
- name: Ensure scripts/processed_files.txt exists
17+
run: |
18+
mkdir -p scripts
19+
if [ ! -f scripts/processed_files.txt ]; then
20+
touch scripts/processed_files.txt
21+
fi
22+
23+
- name: Fetch file list from integration-resources
24+
run: |
25+
curl -s https://api.github.com/repos/appsmithorg/integration-resources/contents/Generic%20UQI%20Creation/uqi_configs \
26+
| jq -r '.[] | select(.type=="file") | .name' > latest_files.txt
27+
28+
- name: Find first unprocessed file
29+
id: detect
30+
run: |
31+
NEW_FILE=$(comm -23 <(sort latest_files.txt) <(sort scripts/processed_files.txt) | head -n 1 || true)
32+
33+
if [ -z "$NEW_FILE" ]; then
34+
echo "No new file to process."
35+
echo "continue=false" >> $GITHUB_ENV
36+
else
37+
echo "Found new file: $NEW_FILE"
38+
echo "$NEW_FILE" > scripts/current_file.txt
39+
echo "new_file=$NEW_FILE" >> $GITHUB_ENV
40+
echo "continue=true" >> $GITHUB_ENV
41+
fi
42+
43+
- name: Exit if no new file
44+
if: env.continue != 'true'
45+
run: exit 0
46+
47+
- name: Download new config file
48+
run: |
49+
FILE_URL="https://raw.githubusercontent.com/appsmithorg/integration-resources/main/Generic%20UQI%20Creation/uqi_configs/${{ env.new_file }}"
50+
curl -sSL "$FILE_URL" -o input_file.txt
51+
52+
- name: Extract Commands (OpenAI Part 1)
53+
run: |
54+
SYSTEM_PROMPT=$(cat .github/prompts/extract_prompt.txt)
55+
USER_CONTENT=$(cat input_file.txt)
56+
57+
PAYLOAD=$(jq -n --arg sys "$SYSTEM_PROMPT" --arg usr "$USER_CONTENT" '{
58+
model: "gpt-4o",
59+
messages: [
60+
{ role: "system", content: $sys },
61+
{ role: "user", content: $usr }
62+
],
63+
temperature: 0
64+
}')
65+
66+
curl -s https://api.openai.com/v1/chat/completions \
67+
-H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \
68+
-H "Content-Type: application/json" \
69+
-d "$PAYLOAD" | jq -r '.choices[0].message.content' > extracted_info.md
70+
71+
- name: Generate Markdown (OpenAI Part 2)
72+
run: |
73+
SYSTEM_PROMPT=$(cat .github/prompts/generate_prompt.txt)
74+
EXTRACTED_CONTENT=$(cat extracted_info.md)
75+
76+
PAYLOAD=$(jq -n --arg sys "$SYSTEM_PROMPT" --arg usr "$EXTRACTED_CONTENT" '{
77+
model: "gpt-4o",
78+
messages: [
79+
{ role: "system", content: $sys },
80+
{ role: "user", content: $usr }
81+
],
82+
temperature: 0.3
83+
}')
84+
85+
curl -s https://api.openai.com/v1/chat/completions \
86+
-H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \
87+
-H "Content-Type: application/json" \
88+
-d "$PAYLOAD" | jq -r '.choices[0].message.content' > generated_doc.md
89+
90+
- name: Prepare target path
91+
id: prep
92+
run: |
93+
INTEGRATION=$(echo "${{ env.new_file }}" | sed 's/\.[^.]*$//' | tr '[:upper:]' '[:lower:]')
94+
FINAL_PATH="website/docs/connect-data/reference/${INTEGRATION}.md"
95+
mkdir -p "$(dirname "$FINAL_PATH")"
96+
cp generated_doc.md "$FINAL_PATH"
97+
echo "integration_name=$INTEGRATION" >> $GITHUB_ENV
98+
echo "final_path=$FINAL_PATH" >> $GITHUB_ENV
99+
100+
- name: Commit and open PR
101+
uses: peter-evans/create-pull-request@v5
102+
with:
103+
token: ${{ secrets.GITHUB_TOKEN }}
104+
title: "docs: add ${{ env.integration_name }} integration reference"
105+
commit-message: "docs: add reference for ${{ env.integration_name }}"
106+
branch: "auto/docs-${{ env.integration_name }}"
107+
base: main
108+
add-paths: |
109+
${{ env.final_path }}
110+
body: |
111+
This PR adds the integration reference documentation for **${{ env.integration_name }}**, generated from:
112+
[`integration-resources/uqi_configs/${{ env.new_file }}`](https://github.com/appsmithorg/integration-resources/blob/main/Generic%20UQI%20Creation/uqi_configs/${{ env.new_file }})
113+
114+
- name: Mark file as processed
115+
run: |
116+
echo "${{ env.new_file }}" >> scripts/processed_files.txt

0 commit comments

Comments
 (0)