Skip to content

Commit 31f9f4a

Browse files
authored
Update sample-file-trigger.yml
1 parent 7094e33 commit 31f9f4a

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

.github/workflows/sample-file-trigger.yml

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: Process Sample Files and Generate Docs
1+
name: Process Sample Files and Create PR
22

33
on:
44
push:
55
paths:
66
- 'website/docs/sample-workflow-tests/**'
77

88
jobs:
9-
process_sample_file:
9+
generate_docs_and_pr:
1010
runs-on: ubuntu-latest
1111

1212
steps:
@@ -18,10 +18,9 @@ jobs:
1818
- name: Detect newly added file
1919
id: detect_files
2020
run: |
21-
echo "Detecting newly added files in sample-workflow-tests/..."
2221
ADDED_FILE=$(git diff --name-status HEAD~1 HEAD | awk '$1 == "A" && $2 ~ /^website\/docs\/sample-workflow-tests\// { print $2 }' | head -n 1)
2322
if [ -z "$ADDED_FILE" ]; then
24-
echo "No new file added in target folder. Exiting."
23+
echo "No new file added in sample-workflow-tests/. Exiting."
2524
exit 0
2625
fi
2726
echo "New file detected: $ADDED_FILE"
@@ -35,8 +34,6 @@ jobs:
3534
3635
- name: Extract Commands and Properties (OpenAI Part 1)
3736
run: |
38-
echo "Calling OpenAI to extract commands and properties..."
39-
4037
SYSTEM_PROMPT=$(cat .github/prompts/extract_prompt.txt)
4138
USER_CONTENT=$(cat input_file.txt)
4239
@@ -54,13 +51,8 @@ jobs:
5451
-H "Content-Type: application/json" \
5552
-d "$PAYLOAD" | jq -r '.choices[0].message.content' > extracted_info.md
5653
57-
echo "✅ Extracted content:"
58-
cat extracted_info.md
59-
6054
- name: Generate Markdown Documentation (OpenAI Part 2)
6155
run: |
62-
echo "Generating final Markdown documentation..."
63-
6456
SYSTEM_PROMPT=$(cat .github/prompts/generate_prompt.txt)
6557
EXTRACTED_CONTENT=$(cat extracted_info.md)
6658
@@ -78,13 +70,42 @@ jobs:
7870
-H "Content-Type: application/json" \
7971
-d "$PAYLOAD" | jq -r '.choices[0].message.content' > generated_doc.md
8072
81-
echo "✅ Generated documentation:"
82-
cat generated_doc.md
73+
- name: Prepare output path and filename
74+
id: prepare_path
75+
run: |
76+
RAW_FILENAME=$(basename "${{ env.file_path }}")
77+
INTEGRATION_NAME=$(echo "$RAW_FILENAME" | sed 's/\.[^.]*$//' | tr '[:upper:]' '[:lower:]')
78+
TARGET_PATH="connect-data/reference/${INTEGRATION_NAME}.md"
79+
80+
echo "Creating path: $TARGET_PATH"
81+
mkdir -p "$(dirname $TARGET_PATH)"
82+
cp generated_doc.md "$TARGET_PATH"
83+
84+
echo "integration_name=$INTEGRATION_NAME" >> $GITHUB_ENV
85+
echo "target_path=$TARGET_PATH" >> $GITHUB_ENV
86+
87+
- name: Commit and push changes to new branch
88+
run: |
89+
BRANCH_NAME="auto/docs-${{ env.integration_name }}"
90+
91+
git config user.name "github-actions[bot]"
92+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
93+
94+
git checkout -b "$BRANCH_NAME"
95+
git add "${{ env.target_path }}"
96+
git commit -m "docs: add integration reference for ${{ env.integration_name }}"
97+
git push origin "$BRANCH_NAME"
8398
84-
- name: Upload documentation artifacts
85-
uses: actions/upload-artifact@v4
99+
- name: Create Pull Request
100+
uses: peter-evans/create-pull-request@v5
86101
with:
87-
name: documentation-files
88-
path: |
89-
extracted_info.md
90-
generated_doc.md
102+
token: ${{ secrets.GITHUB_TOKEN }}
103+
title: "docs: add ${{ env.integration_name }} integration reference"
104+
commit-message: "docs: add integration reference for ${{ env.integration_name }}"
105+
branch: "auto/docs-${{ env.integration_name }}"
106+
base: main
107+
body: |
108+
This PR was automatically generated from a newly added sample file for **${{ env.integration_name }}**.
109+
110+
The integration reference documentation has been created at:
111+
`/connect-data/reference/${{ env.integration_name }}.md`

0 commit comments

Comments
 (0)