Integration Doc Generator #112
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Integration Doc Generator | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| target_branch: | |
| description: 'Branch in appsmith-docs to create PR against' | |
| required: true | |
| default: 'main' | |
| type: string | |
| jobs: | |
| generate_docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout appsmith-docs repo | |
| - name: Checkout appsmith-docs | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
| ref: ${{ github.event.inputs.target_branch }} | |
| fetch-depth: 0 | |
| # Step 2: Set local files to process | |
| - name: Set files to process manually | |
| run: | | |
| echo "intercom_uqi_config.json" > files_to_process.txt | |
| echo "sharepoint_uqi_config.json" >> files_to_process.txt | |
| cat files_to_process.txt | |
| # Step 3: Generate Markdown docs using OpenAI | |
| - name: Generate docs with OpenAI | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| run: | | |
| mkdir -p website/docs/connect-data/reference | |
| while IFS= read -r FILE_NAME; do | |
| echo "⏳ Processing $FILE_NAME" | |
| INPUT_PATH=".github/resources/integration-configs/$FILE_NAME" | |
| if [ ! -f "$INPUT_PATH" ]; then | |
| echo "❌ File not found: $INPUT_PATH" | |
| exit 1 | |
| fi | |
| # Step 1: extract integration details | |
| SYSTEM_PROMPT_1=$(cat .github/prompts/extract_prompt.txt) | |
| USER_INPUT_1=$(cat "$INPUT_PATH") | |
| PAYLOAD_1=$(jq -nc \ | |
| --arg sys "$SYSTEM_PROMPT_1" \ | |
| --arg usr "$USER_INPUT_1" \ | |
| '{model: "gpt-4-1106-preview", messages: [{"role": "system", "content": $sys}, {"role": "user", "content": $usr}], max_tokens: 2000, temperature: 0}') | |
| RESPONSE_1=$(curl -s https://api.openai.com/v1/chat/completions \ | |
| -H "Authorization: Bearer $OPENAI_API_KEY" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$PAYLOAD_1") | |
| if echo "$RESPONSE_1" | jq -e '.error' > /dev/null; then | |
| echo "❌ OpenAI error on extract" | |
| echo "$RESPONSE_1" | jq . | |
| continue | |
| fi | |
| EXTRACTED_CONTENT=$(echo "$RESPONSE_1" | jq -r '.choices[0].message.content') | |
| # Step 2: generate markdown | |
| SYSTEM_PROMPT_2=$(cat .github/prompts/generate_prompt.txt) | |
| PAYLOAD_2=$(jq -nc \ | |
| --arg sys "$SYSTEM_PROMPT_2" \ | |
| --arg usr "$EXTRACTED_CONTENT" \ | |
| '{model: "gpt-4-1106-preview", messages: [{"role": "system", "content": $sys}, {"role": "user", "content": $usr}], max_tokens: 4000, temperature: 0.3}') | |
| RESPONSE_2=$(curl -s https://api.openai.com/v1/chat/completions \ | |
| -H "Authorization: Bearer $OPENAI_API_KEY" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$PAYLOAD_2") | |
| if echo "$RESPONSE_2" | jq -e '.error' > /dev/null; then | |
| echo "❌ OpenAI error on generate" | |
| echo "$RESPONSE_2" | jq . | |
| continue | |
| fi | |
| FINAL_MD=$(echo "$RESPONSE_2" | jq -r '.choices[0].message.content') | |
| INTEGRATION_NAME=$(basename "$FILE_NAME" "_uqi_config.json" | tr '[:upper:]' '[:lower:]') | |
| OUTPUT_FILE="website/docs/connect-data/reference/${INTEGRATION_NAME}.md" | |
| echo "$FINAL_MD" > "$OUTPUT_FILE" | |
| echo "✅ Wrote $OUTPUT_FILE" | |
| done < files_to_process.txt | |
| # Step 4: Create a PR with generated docs | |
| - name: Commit & Create Pull Request | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
| title: "docs: update intercom & sharepoint integration docs" | |
| commit-message: | | |
| docs: generated intercom and sharepoint docs | |
| Processed: intercom_uqi_config.json, sharepoint_uqi_config.json | |
| branch: "docs-update/${{ github.event.inputs.target_branch }}-${{ github.run_id }}" | |
| base: ${{ github.event.inputs.target_branch }} | |
| add-paths: | | |
| website/docs/connect-data/reference/intercom.md | |
| website/docs/connect-data/reference/sharepoint.md | |
| body: | | |
| ✅ Auto-generated documentation for Intercom and SharePoint integrations. |