-
Notifications
You must be signed in to change notification settings - Fork 2
132 lines (119 loc) · 4.37 KB
/
Copy pathdocs-agent.yml
File metadata and controls
132 lines (119 loc) · 4.37 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Docs Agent
on:
workflow_dispatch:
inputs:
mode:
description: Review docs coverage or apply docs updates
required: true
default: review
type: choice
options:
- review
- apply
pr_number:
description: Pull request number to review or update
required: true
type: string
base_ref:
description: Base branch to diff against
required: true
default: main
type: string
head_ref:
description: Optional PR head ref to check out for manual runs
required: false
type: string
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'packages/**/src/**'
- 'agents/**/src/**'
issue_comment:
types: [created]
permissions:
contents: read
jobs:
review-docs:
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.mode == 'review')
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.head_ref || github.event.pull_request.head.sha || github.ref }}
- name: Fetch base branch
run: git fetch origin "${{ github.base_ref || inputs.base_ref }}" --depth=1
- name: Install Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Review docs coverage
env:
FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }}
GH_TOKEN: ${{ github.token }}
run: |
bun run --cwd agents/docs-agent docs-agent:workflow \
--mode review \
--pr-number "${{ github.event.pull_request.number || inputs.pr_number }}" \
--sha "${{ github.event.pull_request.head.sha || github.sha }}" \
--repo "${{ github.repository }}" \
--base-ref "${{ github.base_ref || inputs.base_ref }}"
apply-docs:
if: |
(github.event_name == 'workflow_dispatch' && inputs.mode == 'apply') ||
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '@docs-agent apply') &&
(github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR'))
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Resolve pull request
id: pr
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ "${{ github.event_name }}" = "issue_comment" ]; then
PR_NUMBER="${{ github.event.issue.number }}"
else
PR_NUMBER="${{ inputs.pr_number }}"
fi
gh pr view "$PR_NUMBER" --repo "${{ github.repository }}" --json number,headRefName,headRefOid,baseRefName > pr.json
echo "number=$(jq -r .number pr.json)" >> "$GITHUB_OUTPUT"
echo "head_ref=$(jq -r .headRefName pr.json)" >> "$GITHUB_OUTPUT"
echo "head_sha=$(jq -r .headRefOid pr.json)" >> "$GITHUB_OUTPUT"
echo "base_ref=$(jq -r .baseRefName pr.json)" >> "$GITHUB_OUTPUT"
- name: Checkout pull request branch
uses: actions/checkout@v4
with:
ref: ${{ steps.pr.outputs.head_ref }}
fetch-depth: 0
- name: Fetch base branch
run: git fetch origin "${{ steps.pr.outputs.base_ref }}" --depth=1
- name: Install Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Apply docs updates
env:
FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }}
GH_TOKEN: ${{ github.token }}
GIT_AUTHOR_NAME: docs-agent[bot]
GIT_AUTHOR_EMAIL: docs-agent[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: docs-agent[bot]
GIT_COMMITTER_EMAIL: docs-agent[bot]@users.noreply.github.com
run: |
bun run --cwd agents/docs-agent docs-agent:workflow \
--mode apply \
--pr-number "${{ steps.pr.outputs.number }}" \
--sha "${{ steps.pr.outputs.head_sha }}" \
--repo "${{ github.repository }}" \
--base-ref "${{ steps.pr.outputs.base_ref }}"