Skip to content

Commit f455176

Browse files
Auto check documentation after PR merge
1 parent 809d31c commit f455176

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Auto Review Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
id-token: write
10+
contents: read
11+
12+
jobs:
13+
auto-review-merge:
14+
runs-on: ubuntu-latest
15+
environment: MMI-Samples
16+
env:
17+
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
18+
AZURE_OPENAI_DEPLOYMENT: ${{ secrets.GPT_4_1_MINI }}
19+
AZURE_OPENAI_API_VERSION: "2024-12-01-preview"
20+
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
21+
REPO_NAME: "Azure-Samples/azure-ai-content-understanding-python"
22+
DOC_FILE_FILTER: '\.md$|README|\.ipynb$'
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0 # Required to compare two SHAs in full history
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: '3.12'
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install -r tools/review_file/requirements.txt
39+
40+
- name: Get changed files
41+
id: changed-docs
42+
run: |
43+
# Retrieve list of files changed between the previous commit and the current SHA
44+
git diff --name-only ${{ github.event.before }} ${{ github.sha }} > changed_files.txt
45+
# filter to include only documentation files (e.g., .md, .rst, README, .ipynb)
46+
grep -E "${DOC_FILE_FILTER}" changed_files.txt || true > changed_docs.txt
47+
echo "Files changed with DOC_FILE_FILTER (${DOC_FILE_FILTER}) — could be empty:"
48+
echo "---------------------------------------------------------------"
49+
cat changed_docs.txt
50+
echo "---------------------------------------------------------------"
51+
52+
- name: Azure Login
53+
uses: azure/login@v2
54+
with:
55+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
56+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
57+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
58+
59+
- name: Run review script on each file
60+
run: |
61+
if [ ! -s changed_docs.txt ]; then
62+
echo "No documentation files changed matching DOC_FILE_FILTER (${DOC_FILE_FILTER}). Skipping review step."
63+
else
64+
while read file; do
65+
if [ -n "$file" ]; then
66+
echo "Running review script on file: $file"
67+
INPUT_FILE_PATH="$file" python tools/review_file/review_file.py
68+
fi
69+
done < changed_docs.txt
70+
fi

tools/review_file/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ The `review_file.py` script uses Azure OpenAI and GitHub APIs to automatically r
2929

3030
2. **Install Dependencies**
3131
```bash
32-
pip3 install azure-identity python-dotenv PyGithub openai unidiff requests
32+
pip3 install -r tools/review_file/requirements.txt
3333
```
3434

3535
3. **Run the Script**
3636
```bash
37-
python3 tools/review_file.py
37+
python3 tools/review_file/review_file.py
3838
```
3939
This will:
4040
- Review the file specified by `INPUT_FILE_PATH` using LLM.

tools/review_file/requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
azure-identity
2+
openai
3+
python-dotenv
4+
PyGithub
5+
requests
6+
unidiff

0 commit comments

Comments
 (0)