Skip to content

Commit a701f93

Browse files
committed
Update workflow to create PR for testing docs changes
The workflow now checks for changes in documentation_testing.json and, if detected, creates a pull request using the peter-evans/create-pull-request action instead of pushing directly.
1 parent 31b2aba commit a701f93

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

.github/workflows/testing-docs-update.yml

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ on:
1010
- 'docs/api/testing/**'
1111
- 'docs/_quartodoc-testing.yml'
1212

13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
1317
jobs:
1418
update-testing-docs:
1519
runs-on: ubuntu-latest
20+
if: github.event_name == 'push'
1621

1722
steps:
1823
- name: Checkout repository
@@ -47,16 +52,42 @@ jobs:
4752
repomix docs/api/testing -o shiny/testing/utils/scripts/repomix-output-testing.xml
4853
python shiny/testing/utils/scripts/process_docs.py --input shiny/testing/utils/scripts/repomix-output-testing.xml --output shiny/testing/generator/data/docs/documentation_testing.json
4954
50-
- name: Check for changes
55+
- name: Check for documentation changes
5156
id: git-check
5257
run: |
53-
git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT
58+
# Check if documentation_testing.json has changes
59+
if git diff --exit-code shiny/testing/generator/data/docs/documentation_testing.json; then
60+
echo "changes=false" >> $GITHUB_OUTPUT
61+
echo "No changes detected in documentation_testing.json"
62+
else
63+
echo "changes=true" >> $GITHUB_OUTPUT
64+
echo "Changes detected in documentation_testing.json"
65+
fi
5466
55-
- name: Commit and push changes
56-
if: steps.git-check.outputs.changes == 'true'
67+
- name: Clean up temporary files
5768
run: |
58-
git config --local user.email "[email protected]"
59-
git config --local user.name "GitHub Action"
60-
git add .
61-
git commit -m "Auto-update testing documentation" || exit 0
62-
git push
69+
# Remove temporary XML files
70+
rm -f shiny/testing/utils/scripts/repomix-output-testing.xml
71+
72+
- name: Create Pull Request
73+
if: steps.git-check.outputs.changes == 'true'
74+
uses: peter-evans/create-pull-request@v7
75+
with:
76+
token: ${{ secrets.GITHUB_TOKEN }}
77+
commit-message: "Auto-update testing documentation"
78+
title: "🤖 Auto-update testing documentation"
79+
body: |
80+
This PR was automatically generated to update the testing documentation.
81+
82+
**Changes:**
83+
- Updated `shiny/testing/generator/data/docs/documentation_testing.json`
84+
85+
**Triggered by:**
86+
- Changes to testing documentation in `docs/api/testing/`
87+
- Changes to `docs/_quartodoc-testing.yml`
88+
89+
Please review the changes before merging.
90+
branch: auto-update-testing-docs
91+
delete-branch: true
92+
add-paths: |
93+
shiny/testing/generator/data/docs/documentation_testing.json

0 commit comments

Comments
 (0)