Create jira.json #27
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: Generate Integration Docs and Create PR | |
| on: | |
| push: | |
| paths: | |
| - 'website/docs/sample-workflow-tests/**' | |
| jobs: | |
| generate_docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Detect newly added file | |
| id: detect_files | |
| run: | | |
| ADDED_FILE=$(git diff --name-status HEAD~1 HEAD | awk '$1 == "A" && $2 ~ /^website\/docs\/sample-workflow-tests\// { print $2 }' | head -n 1) | |
| if [ -z "$ADDED_FILE" ]; then | |
| echo "No new file added in sample-workflow-tests/. Exiting." | |
| exit 0 | |
| fi | |
| echo "New file detected: $ADDED_FILE" | |
| echo "file_path=$ADDED_FILE" >> $GITHUB_ENV | |
| - name: Read file content | |
| run: | | |
| echo "Reading: ${{ env.file_path }}" | |
| cat "${{ env.file_path }}" | |
| cp "${{ env.file_path }}" input_file.txt | |
| - name: Extract Commands and Properties (OpenAI Part 1) | |
| run: | | |
| SYSTEM_PROMPT=$(cat .github/prompts/extract_prompt.txt) | |
| USER_CONTENT=$(cat input_file.txt) | |
| PAYLOAD=$(jq -n --arg sys "$SYSTEM_PROMPT" --arg usr "$USER_CONTENT" '{ | |
| model: "gpt-4o", | |
| messages: [ | |
| { role: "system", content: $sys }, | |
| { role: "user", content: $usr } | |
| ], | |
| temperature: 0 | |
| }') | |
| curl -s https://api.openai.com/v1/chat/completions \ | |
| -H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$PAYLOAD" | jq -r '.choices[0].message.content' > extracted_info.md | |
| - name: Generate Markdown Documentation (OpenAI Part 2) | |
| run: | | |
| SYSTEM_PROMPT=$(cat .github/prompts/generate_prompt.txt) | |
| EXTRACTED_CONTENT=$(cat extracted_info.md) | |
| PAYLOAD=$(jq -n --arg sys "$SYSTEM_PROMPT" --arg usr "$EXTRACTED_CONTENT" '{ | |
| model: "gpt-4o", | |
| messages: [ | |
| { role: "system", content: $sys }, | |
| { role: "user", content: $usr } | |
| ], | |
| temperature: 0.3 | |
| }') | |
| curl -s https://api.openai.com/v1/chat/completions \ | |
| -H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$PAYLOAD" | jq -r '.choices[0].message.content' > generated_doc.md | |
| - name: Prepare target path | |
| id: prepare_path | |
| run: | | |
| RAW_FILENAME=$(basename "${{ env.file_path }}") | |
| INTEGRATION_NAME=$(echo "$RAW_FILENAME" | sed 's/\.[^.]*$//' | tr '[:upper:]' '[:lower:]') | |
| TARGET_PATH="website/docs/connect-data/reference/${INTEGRATION_NAME}.md" | |
| echo "Target file: $TARGET_PATH" | |
| mkdir -p "$(dirname "$TARGET_PATH")" | |
| cp generated_doc.md "$TARGET_PATH" | |
| echo "integration_name=$INTEGRATION_NAME" >> $GITHUB_ENV | |
| echo "target_path=$TARGET_PATH" >> $GITHUB_ENV | |
| - name: Commit and create PR | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| title: "docs: add ${{ env.integration_name }} integration reference" | |
| commit-message: "docs: add reference for ${{ env.integration_name }}" | |
| branch: "auto/docs-${{ env.integration_name }}" | |
| base: main | |
| add-paths: | | |
| ${{ env.target_path }} | |
| body: | | |
| This PR adds the generated integration reference for **${{ env.integration_name }}** to: | |
| ``` | |
| /website/docs/connect-data/reference/${{ env.integration_name }}.md | |
| ``` | |
| Generated automatically from sample workflow input. |