Skip to content

Commit 19bc490

Browse files
author
Auto-Co AI
committed
Cycle 12: Pivot — ship DocuCraft as GitHub Action + static site
Same Next Action 3 cycles running -> stall detected -> pivoted. Changes: - Created .github/actions/docucraft/action.yml — composite GitHub Action that auto-generates PR descriptions from diff (template + optional AI mode) - Created .github/workflows/docucraft.yml — dogfooding workflow for this repo - Made repo public + enabled GitHub Pages - Stripped API routes (Supabase/GitHub App/OpenAI — blocked by credentials) - Stripped dashboard (depends on API routes) - Converted to static export (next.config.ts output: 'export') - Updated landing page CTAs to point to GitHub Marketplace - Updated deploy workflow for GitHub Pages deployment
1 parent 21172a8 commit 19bc490

25 files changed

Lines changed: 231 additions & 933 deletions

File tree

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
name: "DocuCraft — PR Description Generator"
2+
description: "Automatically generates structured PR descriptions from pull request diffs."
3+
author: "DocuCraft"
4+
branding:
5+
icon: "file-text"
6+
color: "blue"
7+
8+
inputs:
9+
github-token:
10+
description: "GitHub token (usually secrets.GITHUB_TOKEN)"
11+
required: true
12+
openai-api-key:
13+
description: "Optional OpenAI API key for AI-powered descriptions"
14+
required: false
15+
openai-model:
16+
description: "OpenAI model to use (default: gpt-4o-mini)"
17+
required: false
18+
default: "gpt-4o-mini"
19+
mode:
20+
description: "Generation mode: template (default) or ai"
21+
required: false
22+
default: "template"
23+
update-title:
24+
description: "Whether to update the PR title with a generated one (true/false)"
25+
required: false
26+
default: "false"
27+
28+
outputs:
29+
description:
30+
description: "The generated PR description"
31+
value: ${{ steps.generate.outputs.description }}
32+
33+
runs:
34+
using: "composite"
35+
steps:
36+
- name: Get PR diff
37+
id: diff
38+
shell: bash
39+
env:
40+
GH_TOKEN: ${{ inputs.github-token }}
41+
run: |
42+
PR_NUMBER=${{ github.event.pull_request.number }}
43+
if [ -z "$PR_NUMBER" ]; then
44+
echo "error=Not a pull request event" >> $GITHUB_OUTPUT
45+
exit 1
46+
fi
47+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
48+
echo "title<<EOF" >> $GITHUB_OUTPUT
49+
echo "${{ github.event.pull_request.title }}" >> $GITHUB_OUTPUT
50+
echo "EOF" >> $GITHUB_OUTPUT
51+
echo "body<<EOF" >> $GITHUB_OUTPUT
52+
echo "${{ github.event.pull_request.body }}" >> $GITHUB_OUTPUT
53+
echo "EOF" >> $GITHUB_OUTPUT
54+
55+
gh pr diff $PR_NUMBER --color=never > /tmp/pr_diff.txt 2>&1 || true
56+
DIFF_SIZE=$(wc -c < /tmp/pr_diff.txt)
57+
if [ "$DIFF_SIZE" -gt 32000 ]; then
58+
head -c 32000 /tmp/pr_diff.txt > /tmp/pr_diff_truncated.txt
59+
mv /tmp/pr_diff_truncated.txt /tmp/pr_diff.txt
60+
fi
61+
echo "diff_size=$DIFF_SIZE" >> $GITHUB_OUTPUT
62+
gh pr view $PR_NUMBER --json files --jq '.files[].path' > /tmp/pr_files.txt 2>&1 || true
63+
64+
- name: Generate description (template mode)
65+
id: generate
66+
shell: bash
67+
if: ${{ inputs.mode != 'ai' || inputs.openai-api-key == '' }}
68+
env:
69+
GH_TOKEN: ${{ inputs.github-token }}
70+
run: |
71+
PR_NUMBER="${{ steps.diff.outputs.pr_number }}"
72+
PR_TITLE="${{ steps.diff.outputs.title }}"
73+
74+
FILES_LIST=""
75+
while IFS= read -r file; do
76+
FILES_LIST="$FILES_LIST- $file"$'\n'
77+
done < /tmp/pr_files.txt
78+
79+
DIFF_PREVIEW=""
80+
if [ -f /tmp/pr_diff.txt ]; then
81+
DIFF_PREVIEW=$(head -c 2000 /tmp/pr_diff.txt)
82+
fi
83+
84+
DESCRIPTION=$(cat <<DESC_EOF
85+
## Summary
86+
87+
<!-- Generated by DocuCraft -->
88+
89+
This pull request introduces changes to the following files:
90+
91+
$FILES_LIST
92+
93+
### Changes
94+
95+
- $(echo "$FILES_LIST" | head -5 | tr '\n' ' ' | sed 's/- //g' | awk '{print "Modified: "$0}')
96+
97+
### Why
98+
99+
Automated pull request description generated by DocuCraft. Review the diff for detailed changes.
100+
101+
---
102+
103+
> 🤖 This description was automatically generated by [DocuCraft](https://github.com/${{ github.repository }}/actions).
104+
DESC_EOF
105+
)
106+
echo "description<<EOF" >> $GITHUB_OUTPUT
107+
echo "$DESCRIPTION" >> $GITHUB_OUTPUT
108+
echo "EOF" >> $GITHUB_OUTPUT
109+
110+
- name: Generate description (AI mode)
111+
id: generate-ai
112+
shell: bash
113+
if: ${{ inputs.mode == 'ai' && inputs.openai-api-key != '' }}
114+
env:
115+
OPENAI_API_KEY: ${{ inputs.openai-api-key }}
116+
run: |
117+
PR_TITLE="${{ steps.diff.outputs.title }}"
118+
FILES_LIST=$(cat /tmp/pr_files.txt 2>/dev/null || echo "No files detected")
119+
DIFF=$(cat /tmp/pr_diff.txt 2>/dev/null || echo "No diff available")
120+
121+
PROMPT=$(cat <<PROMPT_EOF
122+
You are DocuCraft, an expert code reviewer. Given this pull request, write a clear and concise PR description.
123+
124+
PR Title: $PR_TITLE
125+
126+
Files Changed:
127+
$FILES_LIST
128+
129+
Diff (truncated):
130+
\`\`\`diff
131+
${DIFF:0:8000}
132+
\`\`\`
133+
134+
Generate a PR description with markdown:
135+
1. **Summary**: 1-2 sentence overview
136+
2. **Changes**: Key changes organized by area
137+
3. **Why**: Motivation behind the changes
138+
PROMPT_EOF
139+
)
140+
JSON_ESCAPED=$(echo "$PROMPT" | jq -Rs .)
141+
RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \
142+
-H "Authorization: Bearer $OPENAI_API_KEY" \
143+
-H "Content-Type: application/json" \
144+
-d "{\"model\":\"${{ inputs.openai-model }}\",\"messages\":[{\"role\":\"user\",\"content\":$JSON_ESCAPED}],\"temperature\":0.3,\"max_tokens\":1000}")
145+
DESCRIPTION=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // "Failed to generate AI description."')
146+
echo "description<<EOF" >> $GITHUB_OUTPUT
147+
echo "$DESCRIPTION" >> $GITHUB_OUTPUT
148+
echo "EOF" >> $GITHUB_OUTPUT
149+
150+
- name: Update PR body
151+
shell: bash
152+
env:
153+
GH_TOKEN: ${{ inputs.github-token }}
154+
run: |
155+
PR_NUMBER="${{ steps.diff.outputs.pr_number }}"
156+
DESCRIPTION="${{ steps.generate.outputs.description }}"
157+
if [ -z "$DESCRIPTION" ]; then
158+
DESCRIPTION="${{ steps.generate-ai.outputs.description }}"
159+
fi
160+
if [ -n "$DESCRIPTION" ]; then
161+
echo "$DESCRIPTION" | gh pr review $PR_NUMBER --body-file - 2>&1 || true
162+
fi

.github/workflows/deploy.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
name: Deploy
1+
name: Deploy to GitHub Pages
22

33
on:
44
push:
55
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: true
616

717
jobs:
818
build:
@@ -15,3 +25,16 @@ jobs:
1525
cache: npm
1626
- run: npm ci
1727
- run: npm run build
28+
- uses: actions/configure-pages@v4
29+
- uses: actions/upload-pages-artifact@v3
30+
with:
31+
path: out
32+
deploy:
33+
needs: build
34+
runs-on: ubuntu-latest
35+
environment:
36+
name: github-pages
37+
url: ${{ steps.deployment.outputs.page_url }}
38+
steps:
39+
- id: deployment
40+
uses: actions/deploy-pages@v4

.github/workflows/docucraft.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: DocuCraft — Auto PR Descriptions
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
generate-description:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Generate PR description
17+
uses: ./.github/actions/docucraft
18+
with:
19+
github-token: ${{ secrets.GITHUB_TOKEN }}

next.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
4-
/* config options here */
4+
output: "export",
5+
images: {
6+
unoptimized: true,
7+
},
58
};
69

710
export default nextConfig;

src/app/api/changelogs/route.ts

Lines changed: 0 additions & 97 deletions
This file was deleted.

src/app/api/github/auth/route.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)