|
1
|
name: DX Triage Doc Fixes |
|
2
|
|
|
3
|
on: |
|
4
|
schedule: |
|
5
|
- cron: "0 9 * * *" # Every day at 09:00 UTC |
|
6
|
workflow_dispatch: |
|
7
|
inputs: |
|
8
|
all_issues: |
|
9
|
description: "Process ALL triage issues (not just the past 24 hours)" |
|
10
|
type: boolean |
|
11
|
default: false |
|
12
|
required: false |
|
13
|
|
|
14
|
concurrency: |
|
15
|
group: dx-triage-doc-fixes |
|
16
|
cancel-in-progress: false |
|
17
|
|
|
18
|
jobs: |
|
19
|
fix-docs: |
|
20
|
runs-on: ubuntu-latest |
|
21
|
permissions: |
|
22
|
contents: write |
|
23
|
pull-requests: write |
|
24
|
steps: |
|
25
|
- name: Generate GitHub App token |
|
26
|
id: app-token |
|
27
|
uses: actions/create-github-app-token@v1 |
|
28
|
with: |
|
29
|
app-id: ${{ secrets.MEDUSA_APP_ID }} |
|
30
|
private-key: ${{ secrets.MEDUSA_APP_PRIVATE_KEY }} |
|
31
|
|
|
32
|
- name: Checkout repository |
|
33
|
uses: actions/checkout@v4 |
|
34
|
with: |
|
35
|
fetch-depth: 0 |
|
36
|
token: ${{ steps.app-token.outputs.token }} |
|
37
|
|
|
38
|
- name: Configure git |
|
39
|
run: | |
|
40
|
git config user.name "github-actions[bot]" |
|
41
|
git config user.email "github-actions[bot]@users.noreply.github.com" |
|
42
|
|
|
43
|
- name: Compute date cutoff |
|
44
|
id: date |
|
45
|
run: | |
|
46
|
CUTOFF=$(date -d '24 hours ago' --utc +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || \ |
|
47
|
date -v -24H -u +%Y-%m-%dT%H:%M:%SZ) |
|
48
|
echo "cutoff=$CUTOFF" >> $GITHUB_OUTPUT |
|
49
|
|
|
50
|
- name: Checkout or create triage fixes branch |
|
51
|
id: branch |
|
52
|
run: | |
|
53
|
BRANCH="docs/dx-triage-fixes-$(date +%Y-%m-%d)" |
|
54
|
git fetch origin |
|
55
|
if git ls-remote --exit-code origin "$BRANCH" > /dev/null 2>&1; then |
|
56
|
git checkout "$BRANCH" |
|
57
|
git merge origin/develop -m "chore: sync $BRANCH with develop" |
|
58
|
echo "Checked out and synced existing branch $BRANCH" |
|
59
|
else |
|
60
|
git checkout -b "$BRANCH" |
|
61
|
echo "Created new branch $BRANCH" |
|
62
|
fi |
|
63
|
echo "name=$BRANCH" >> $GITHUB_OUTPUT |
|
64
|
|
|
65
|
- name: Run Claude Code to fix docs |
|
66
|
uses: anthropics/claude-code-base-action@132be24009ca6f292db66a3d1d5a17249cf68a5d # main, installs Claude Code 2.1.282 |
|
67
|
with: |
|
68
|
anthropic_api_key: ${{ secrets.CLAUDE_CODE_API_TOKEN }} |
|
69
|
claude_args: >- |
|
70
|
--model claude-opus-5-5 |
|
71
|
--max-turns 80 |
|
72
|
--mcp-config '{"mcpServers":{"linear-server":{"type":"http","url":"https://mcp.linear.app/mcp","headers":{"Authorization":"Bearer ${{ secrets.LINEAR_API_KEY }}"}}}}' |
|
73
|
--allowedTools "Skill,Read,Write,Edit,Glob,Grep,mcp__linear-server__list_teams,mcp__linear-server__list_issues,mcp__linear-server__get_issue,mcp__linear-server__list_issue_statuses,Bash(git diff:*),Bash(git status:*),Bash(ls:*),Bash(find:*),Bash(cat:*)" |
|
74
|
prompt: | |
|
75
|
IMPORTANT: Only make file changes using the Write and Edit tools. Never use git commands to stage, commit, or push files. |
|
76
|
|
|
77
|
IMPORTANT: Before making any documentation changes, read the writing-docs guidelines by reading this file using the Read tool: .claude/skills/writing-docs/SKILL.md |
|
78
|
Then read whichever reference files the skill instructs you to load for the relevant project (book, resources, user-guide, ui, or cloud). Do NOT use any MCP tools or sub-agents to load these files — use the Read tool only. |
|
79
|
|
|
80
|
You are fixing Medusa documentation based on feedback issues from the DX team triage inbox in Linear. |
|
81
|
|
|
82
|
## Step 1 — Fetch issues |
|
83
|
|
|
84
|
Use the Linear MCP tools to fetch issues with: |
|
85
|
- Team: DX |
|
86
|
- Status: Triage |
|
87
|
|
|
88
|
${{ inputs.all_issues == true && 'DATE FILTER: Process ALL triage issues regardless of when they were created.' || format('DATE FILTER: Only process issues created in the last 24 hours (after {0}). Skip any issue with a createdAt timestamp earlier than this date.', steps.date.outputs.cutoff) }} |
|
89
|
|
|
90
|
## Step 2 — Filter issues |
|
91
|
|
|
92
|
For each issue, SKIP it entirely if ANY of the following are true: |
|
93
|
- The issue is not about documentation content (e.g. it is a code bug, feature request, or SDK behaviour issue unrelated to doc pages) |
|
94
|
- The issue mentions or links to pages under these auto-generated paths: |
|
95
|
resources/references/ |
|
96
|
api-reference/ |
|
97
|
ui/specs/components/ |
|
98
|
- The feedback is too vague to act on (e.g. message is just "no" or a single word with no actionable detail) |
|
99
|
- Fixing it would require API design decisions, new feature work, or large architectural rewrites — only fix self-contained doc edits (incorrect code samples, misleading prose, missing explanations, outdated examples) |
|
100
|
|
|
101
|
## Step 3 — Fix each qualifying issue |
|
102
|
|
|
103
|
For each qualifying issue: |
|
104
|
1. Identify the relevant doc file from the page path or URL mentioned in the issue |
|
105
|
2. Read the MDX file(s) |
|
106
|
3. Validate that the issue is accurate. You can look at any necessary source code under the `packages` directory to verify if the documentation is indeed incorrect or missing information. For issues not in source code, evaluate the issue based on the content of the doc page and your understanding of good documentation and coding practices. |
|
107
|
4. Apply the fix following the writing-docs skill guidelines |
|
108
|
5. Only write to these directories: |
|
109
|
- www/apps/book |
|
110
|
- www/apps/resources |
|
111
|
- www/apps/user-guide |
|
112
|
- www/apps/ui |
|
113
|
- www/apps/cloud |
|
114
|
6. Never touch www/apps/resources/references/, www/apps/api-reference/, or www/apps/ui/specs/components/ |
|
115
|
|
|
116
|
## Step 4 — Write fixed issue IDs |
|
117
|
|
|
118
|
After applying all fixes, write a file at /tmp/fixed-issues.txt. |
|
119
|
Write one issue identifier per line (e.g. DX-2591). No URLs, no extra text. |
|
120
|
|
|
121
|
If no issues qualified or were fixed, write an empty file. |
|
122
|
|
|
123
|
Example /tmp/fixed-issues.txt: |
|
124
|
DX-2591 |
|
125
|
DX-2593 |
|
126
|
|
|
127
|
## Step 5 — Write the PR title and summary |
|
128
|
|
|
129
|
After applying all fixes, write these two files using the Write tool: |
|
130
|
|
|
131
|
1. /tmp/pr-title.txt — a single-line pull request title. It MUST start with "docs: ", followed by a concise summary of what was changed, and MUST end with " [automated]". Keep it under 100 characters. Example: "docs: fix incorrect subscriber examples and payment provider setup [automated]" |
|
132
|
2. /tmp/pr-summary.md — a short summary (2-4 sentences, or a few bullet points) of what was updated. Plain markdown, no top-level heading. |
|
133
|
|
|
134
|
If no issues qualified or were fixed, do not create either file. |
|
135
|
|
|
136
|
- name: Stage documentation changes |
|
137
|
id: changes |
|
138
|
run: | |
|
139
|
git add www/apps/book www/apps/resources www/apps/user-guide www/apps/ui www/apps/cloud |
|
140
|
if git diff --staged --quiet; then |
|
141
|
echo "has_changes=false" >> $GITHUB_OUTPUT |
|
142
|
echo "No documentation changes to commit." |
|
143
|
else |
|
144
|
echo "has_changes=true" >> $GITHUB_OUTPUT |
|
145
|
fi |
|
146
|
|
|
147
|
- name: Read fixed issue IDs |
|
148
|
id: fixed-ids |
|
149
|
run: | |
|
150
|
if [ -f /tmp/fixed-issues.txt ] && [ -s /tmp/fixed-issues.txt ]; then |
|
151
|
IDS=$(cat /tmp/fixed-issues.txt | grep -v '^$' | tr '\n' ',' | sed 's/,$//' | sed 's/,/, /g') |
|
152
|
echo "ids=$IDS" >> $GITHUB_OUTPUT |
|
153
|
echo "Fixed issues: $IDS" |
|
154
|
else |
|
155
|
echo "ids=" >> $GITHUB_OUTPUT |
|
156
|
echo "No issues fixed." |
|
157
|
fi |
|
158
|
|
|
159
|
- name: Read Claude-generated PR metadata |
|
160
|
id: pr-meta |
|
161
|
if: steps.changes.outputs.has_changes == 'true' |
|
162
|
run: | |
|
163
|
TITLE="" |
|
164
|
if [ -s /tmp/pr-title.txt ]; then |
|
165
|
TITLE=$(head -n 1 /tmp/pr-title.txt | sed 's/[[:space:]]*$//') |
|
166
|
fi |
|
167
|
# Fall back to a static title if Claude's title is missing or malformed |
|
168
|
case "$TITLE" in |
|
169
|
"docs: "*"[automated]") ;; |
|
170
|
*) TITLE="docs: fix documentation issues in triage inbox [automated]" ;; |
|
171
|
esac |
|
172
|
echo "title=$TITLE" >> "$GITHUB_OUTPUT" |
|
173
|
|
|
174
|
- name: Commit documentation changes |
|
175
|
if: steps.changes.outputs.has_changes == 'true' |
|
176
|
run: | |
|
177
|
git commit -m "docs: fix documentation issues from triage inbox" |
|
178
|
|
|
179
|
- name: Push branch |
|
180
|
if: steps.changes.outputs.has_changes == 'true' |
|
181
|
run: git push origin ${{ steps.branch.outputs.name }} |
|
182
|
|
|
183
|
- name: Create or update Pull Request |
|
184
|
if: steps.changes.outputs.has_changes == 'true' |
|
185
|
env: |
|
186
|
GH_TOKEN: ${{ steps.app-token.outputs.token }} |
|
187
|
REPO: ${{ github.repository }} |
|
188
|
BRANCH: ${{ steps.branch.outputs.name }} |
|
189
|
FIXED_IDS: ${{ steps.fixed-ids.outputs.ids }} |
|
190
|
PR_TITLE: ${{ steps.pr-meta.outputs.title }} |
|
191
|
run: | |
|
192
|
BODY_FILE=$(mktemp) |
|
193
|
|
|
194
|
cat > "$BODY_FILE" << 'BODY_EOF' |
|
195
|
## Fix documentation issues in triage inbox |
|
196
|
|
|
197
|
This PR fixes documentation issues from the triage inbox. |
|
198
|
Each issue was evaluated by Claude and deemed a self-contained doc fix. |
|
199
|
BODY_EOF |
|
200
|
|
|
201
|
echo "" >> "$BODY_FILE" |
|
202
|
if [ -s /tmp/pr-summary.md ]; then |
|
203
|
cat /tmp/pr-summary.md >> "$BODY_FILE" |
|
204
|
else |
|
205
|
echo "_No summary was generated._" >> "$BODY_FILE" |
|
206
|
fi |
|
207
|
|
|
208
|
cat >> "$BODY_FILE" << 'BODY_EOF' |
|
209
|
|
|
210
|
> Review carefully before merging. Claude may have missed context or made |
|
211
|
> incorrect assumptions. |
|
212
|
BODY_EOF |
|
213
|
|
|
214
|
if [ -n "$FIXED_IDS" ]; then |
|
215
|
echo "" >> "$BODY_FILE" |
|
216
|
echo "Closes $FIXED_IDS" >> "$BODY_FILE" |
|
217
|
fi |
|
218
|
|
|
219
|
REPO_OWNER="${REPO%%/*}" |
|
220
|
PR_NUMBER=$(gh api "repos/$REPO/pulls?head=${REPO_OWNER}:${BRANCH}&state=open" \ |
|
221
|
--jq '.[0].number' 2>/dev/null || echo "") |
|
222
|
|
|
223
|
if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then |
|
224
|
gh api "repos/$REPO/pulls/$PR_NUMBER" \ |
|
225
|
--method PATCH \ |
|
226
|
--field title="$PR_TITLE" \ |
|
227
|
--field body="$(cat "$BODY_FILE")" |
|
228
|
echo "Updated PR #$PR_NUMBER" |
|
229
|
else |
|
230
|
PR_NUMBER=$(gh api "repos/$REPO/pulls" \ |
|
231
|
--method POST \ |
|
232
|
--field title="$PR_TITLE" \ |
|
233
|
--field body="$(cat "$BODY_FILE")" \ |
|
234
|
--field base="develop" \ |
|
235
|
--field head="$BRANCH" \ |
|
236
|
--jq '.number') |
|
237
|
gh api "repos/$REPO/issues/$PR_NUMBER/labels" \ |
|
238
|
--method POST \ |
|
239
|
--field 'labels[]=type: docs' |
|
240
|
echo "Created PR #$PR_NUMBER" |
|
241
|
fi |