-
Notifications
You must be signed in to change notification settings - Fork 65
66 lines (56 loc) · 2.08 KB
/
Copy pathgenerate-from-pr.yaml
File metadata and controls
66 lines (56 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Generate Documentation from MoonShine PR
on:
repository_dispatch:
types: [moonshine_pr_merged]
# Security: Restrict permissions to minimum required
permissions:
contents: write
pull-requests: write
jobs:
generate-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout doc repo
uses: actions/checkout@v4
with:
ref: 4.x
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install openai
- name: Generate documentation with OpenAI
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
PR_URL: ${{ github.event.client_payload.pr_url }}
PR_NUMBER: ${{ github.event.client_payload.pr_number }}
PR_TITLE: ${{ github.event.client_payload.pr_title }}
PR_DIFF: ${{ github.event.client_payload.pr_diff }}
run: |
python .github/scripts/generate_docs.py
- name: Check if documentation changes were generated
id: check_changes
run: |
if [ -f .github/.no_docs_needed ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "No documentation changes needed, skipping PR creation."
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Create Pull Request
if: steps.check_changes.outputs.skip != 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: docs/auto-pr-${{ github.event.client_payload.pr_number }}
title: "docs: Generated from moonshine#${{ github.event.client_payload.pr_number }}"
body: |
Auto-generated documentation from merged PR: ${{ github.event.client_payload.pr_url }}
**Original PR:** ${{ github.event.client_payload.pr_title }}
- [ ] En
- [ ] Ru
commit-message: "docs: Generated from moonshine PR #${{ github.event.client_payload.pr_number }}"
base: 4.x