Skip to content

Commit 8561562

Browse files
committed
Add a github action to auto PR to core
1 parent d7e2752 commit 8561562

File tree

3 files changed

+430
-0
lines changed

3 files changed

+430
-0
lines changed

.github/workflows/AUTO_PR_SETUP.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# Auto PR to ComfyUI Setup Guide
2+
3+
This document explains how to set up and use the automated PR workflow that syncs `embedded-docs` version updates to the ComfyUI repository.
4+
5+
## 🎯 What This Workflow Does
6+
7+
When you bump the version in `pyproject.toml` on the `main` branch, this workflow automatically:
8+
9+
1. ✅ Detects the version change
10+
2. ✅ Generates a changelog from commits and merged PRs
11+
3. ✅ Updates `requirements.txt` in your ComfyUI fork
12+
4. ✅ Creates a new branch with format: `update-docs-{VERSION}-{TIMESTAMP}`
13+
5. ✅ Submits a **draft PR** to `comfyanonymous/ComfyUI`
14+
6. ✅ Sends you a GitHub notification
15+
16+
## 🔧 Setup Instructions
17+
18+
### 1. Create a GitHub Personal Access Token (PAT)
19+
20+
You need a PAT with permissions to:
21+
- Push to `comfyui-wiki/ComfyUI` (your fork)
22+
- Create PRs on `comfyanonymous/ComfyUI` (target repository)
23+
24+
**Steps:**
25+
1. Go to: https://github.com/settings/tokens/new
26+
2. Select **Fine-grained tokens** (recommended) or **Classic token**
27+
3. Configure the token:
28+
- **Name**: `ComfyUI Auto PR Token`
29+
- **Expiration**: Choose based on your preference
30+
- **Repository access**:
31+
- Select "Only select repositories"
32+
- Add: `comfyui-wiki/ComfyUI`
33+
- **Permissions**:
34+
- Repository permissions:
35+
- Contents: Read and write
36+
- Pull requests: Read and write
37+
- Metadata: Read-only (automatic)
38+
39+
4. Click **Generate token** and copy it immediately (you won't see it again!)
40+
41+
### 2. Add the Token to Repository Secrets
42+
43+
1. Go to your `embedded-docs` repository
44+
2. Navigate to: **Settings****Secrets and variables****Actions**
45+
3. Click **New repository secret**
46+
4. Add the secret:
47+
- **Name**: `COMFYUI_FORK_TOKEN`
48+
- **Value**: Paste your PAT from step 1
49+
5. Click **Add secret**
50+
51+
### 3. Verify the Workflow File
52+
53+
The workflow file is located at: `.github/workflows/auto-pr-to-comfyui.yml`
54+
55+
Make sure these values are correct:
56+
- Fork repository: `comfyui-wiki/ComfyUI`
57+
- Target repository: `comfyanonymous/ComfyUI`
58+
- Target branch: `master`
59+
- Requirements file: `requirements.txt`
60+
61+
## 📋 How to Use
62+
63+
### Normal Workflow
64+
65+
1. Make your changes to documentation
66+
2. Update the version in `pyproject.toml`
67+
3. Commit and push to `main` branch
68+
4. The workflow triggers automatically
69+
5. You'll receive a GitHub notification when the draft PR is created
70+
6. Review the draft PR at: https://github.com/comfyanonymous/ComfyUI/pulls
71+
72+
### Manual Trigger
73+
74+
Currently, the workflow only triggers on version changes. If you need to manually trigger it, you can add this to the workflow:
75+
76+
```yaml
77+
on:
78+
workflow_dispatch: # Add this line
79+
push:
80+
branches: [main]
81+
paths:
82+
- "pyproject.toml"
83+
```
84+
85+
## 📬 Notifications
86+
87+
You will automatically receive GitHub notifications when:
88+
- ✅ A draft PR is created
89+
- ✅ Someone comments on the PR
90+
- ✅ The PR status changes
91+
92+
**To ensure you receive notifications:**
93+
1. Go to: https://github.com/settings/notifications
94+
2. Make sure these are enabled:
95+
- ✅ Email notifications
96+
- ✅ Pull requests
97+
- ✅ Participating (for PRs you created)
98+
99+
## 🔍 Troubleshooting
100+
101+
### Problem: Workflow doesn't trigger
102+
103+
**Solutions:**
104+
- Check that the file changed is exactly `pyproject.toml`
105+
- Verify you pushed to the `main` branch
106+
- Check workflow runs at: `https://github.com/Comfy-Org/embedded-docs/actions`
107+
108+
### Problem: Authentication failed
109+
110+
**Solutions:**
111+
- Verify the `COMFYUI_FORK_TOKEN` secret is set correctly
112+
- Check that your PAT hasn't expired
113+
- Ensure the PAT has the correct permissions
114+
115+
### Problem: PR creation fails
116+
117+
**Solutions:**
118+
- Verify that `comfyui-wiki/ComfyUI` fork exists
119+
- Check that the fork is up to date with upstream
120+
- Ensure `requirements.txt` exists in the fork
121+
122+
### Problem: No notifications received
123+
124+
**Solutions:**
125+
- Check your GitHub notification settings
126+
- Look at: https://github.com/notifications
127+
- Verify email settings in your GitHub profile
128+
129+
## 📝 PR Content Structure
130+
131+
The generated draft PR includes:
132+
133+
```markdown
134+
## Update embedded docs to v{VERSION}
135+
136+
### 📦 Package Information
137+
- **PyPI**: https://pypi.org/project/comfyui-embedded-docs/{VERSION}/
138+
- **Release**: https://github.com/Comfy-Org/embedded-docs/releases/tag/v{VERSION}
139+
140+
### 📝 Changes since v{PREV_VERSION}
141+
142+
#### Merged Pull Requests
143+
- PR #123: Add documentation for new nodes
144+
- PR #124: Fix typos in CLIPLoader docs
145+
146+
#### Commits
147+
- abc1234: Update Spanish translations
148+
- def5678: Add images for flux nodes
149+
150+
---
151+
*This is an automated draft PR created by the embedded-docs sync workflow.*
152+
```
153+
154+
## 🔐 Security Notes
155+
156+
- ⚠️ **Never commit tokens directly** to the repository
157+
- ✅ Always use GitHub Secrets for sensitive data
158+
- ✅ Use fine-grained tokens with minimal required permissions
159+
- ✅ Regularly rotate your tokens (every 6-12 months)
160+
- ✅ Audit token usage in GitHub settings
161+
162+
## 📊 Workflow Visualization
163+
164+
```
165+
Version Bump in pyproject.toml
166+
167+
Workflow Triggers
168+
169+
Extract Version Info
170+
171+
Generate Changelog
172+
173+
Clone ComfyUI Fork
174+
175+
Update requirements.txt
176+
177+
Create New Branch
178+
179+
Push to Fork
180+
181+
Create Draft PR
182+
183+
GitHub Notification Sent
184+
```
185+
186+
## 🆘 Support
187+
188+
If you encounter issues:
189+
1. Check the workflow logs in GitHub Actions
190+
2. Verify all settings in this guide
191+
3. Test with a minor version bump first (e.g., 0.3.0 → 0.3.1)
192+
193+
## 📚 Related Files
194+
195+
- Workflow: `.github/workflows/auto-pr-to-comfyui.yml`
196+
- Publish workflow: `.github/workflows/publish.yml`
197+
- Version file: `pyproject.toml`
198+
- Target file: `requirements.txt` (in ComfyUI fork)
199+
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
name: Auto PR to ComfyUI on Version Bump
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "pyproject.toml"
8+
9+
jobs:
10+
create-pr:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout embedded-docs repo
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0 # Get full history for changelog generation
18+
19+
- name: Get current version
20+
id: current_version
21+
run: |
22+
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
23+
echo "version=$VERSION" >> $GITHUB_OUTPUT
24+
echo "Current version: $VERSION"
25+
26+
- name: Get previous version
27+
id: previous_version
28+
run: |
29+
# Get the previous version tag
30+
PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
31+
if [ -z "$PREV_TAG" ]; then
32+
echo "version=0.0.0" >> $GITHUB_OUTPUT
33+
echo "No previous version tag found, using 0.0.0"
34+
else
35+
PREV_VERSION=${PREV_TAG#v}
36+
echo "version=$PREV_VERSION" >> $GITHUB_OUTPUT
37+
echo "tag=$PREV_TAG" >> $GITHUB_OUTPUT
38+
echo "Previous version: $PREV_VERSION (tag: $PREV_TAG)"
39+
fi
40+
41+
- name: Check if version changed
42+
id: version_check
43+
run: |
44+
CURRENT="${{ steps.current_version.outputs.version }}"
45+
PREVIOUS="${{ steps.previous_version.outputs.version }}"
46+
47+
if [ "$CURRENT" != "$PREVIOUS" ]; then
48+
echo "changed=true" >> $GITHUB_OUTPUT
49+
echo "✅ Version bumped from $PREVIOUS to $CURRENT"
50+
else
51+
echo "changed=false" >> $GITHUB_OUTPUT
52+
echo "ℹ️ No version change detected"
53+
fi
54+
55+
- name: Generate changelog
56+
id: changelog
57+
if: steps.version_check.outputs.changed == 'true'
58+
run: |
59+
PREV_TAG="${{ steps.previous_version.outputs.tag }}"
60+
CURRENT_VERSION="${{ steps.current_version.outputs.version }}"
61+
62+
# Create changelog file
63+
CHANGELOG_FILE="pr_changelog.md"
64+
65+
echo "## Update embedded docs to v${CURRENT_VERSION}" > $CHANGELOG_FILE
66+
echo "" >> $CHANGELOG_FILE
67+
echo "### 📦 Package Information" >> $CHANGELOG_FILE
68+
echo "- **PyPI**: https://pypi.org/project/comfyui-embedded-docs/${CURRENT_VERSION}/" >> $CHANGELOG_FILE
69+
echo "- **Release**: https://github.com/Comfy-Org/embedded-docs/releases/tag/v${CURRENT_VERSION}" >> $CHANGELOG_FILE
70+
echo "" >> $CHANGELOG_FILE
71+
72+
if [ -n "$PREV_TAG" ]; then
73+
echo "### 📝 Changes since ${PREV_TAG}" >> $CHANGELOG_FILE
74+
echo "" >> $CHANGELOG_FILE
75+
76+
# Get merged PRs
77+
echo "#### Merged Pull Requests" >> $CHANGELOG_FILE
78+
git log ${PREV_TAG}..HEAD --merges --pretty=format:"- %s (%h)" | grep -i "Merge pull request" | sed 's/Merge pull request/PR/' >> $CHANGELOG_FILE || echo "- No merged PRs found" >> $CHANGELOG_FILE
79+
echo "" >> $CHANGELOG_FILE
80+
81+
# Get commits (excluding merge commits)
82+
echo "#### Commits" >> $CHANGELOG_FILE
83+
git log ${PREV_TAG}..HEAD --no-merges --pretty=format:"- %s (%h)" >> $CHANGELOG_FILE
84+
echo "" >> $CHANGELOG_FILE
85+
else
86+
echo "### 📝 Initial Release" >> $CHANGELOG_FILE
87+
echo "" >> $CHANGELOG_FILE
88+
echo "This is the initial automated sync of the embedded-docs package." >> $CHANGELOG_FILE
89+
echo "" >> $CHANGELOG_FILE
90+
fi
91+
92+
echo "" >> $CHANGELOG_FILE
93+
echo "---" >> $CHANGELOG_FILE
94+
echo "*This is an automated draft PR created by the embedded-docs sync workflow.*" >> $CHANGELOG_FILE
95+
96+
echo "changelog_file=$CHANGELOG_FILE" >> $GITHUB_OUTPUT
97+
98+
echo "📄 Generated changelog:"
99+
cat $CHANGELOG_FILE
100+
101+
- name: Checkout ComfyUI fork
102+
if: steps.version_check.outputs.changed == 'true'
103+
uses: actions/checkout@v4
104+
with:
105+
repository: 'comfyui-wiki/ComfyUI'
106+
token: ${{ secrets.COMFYUI_FORK_TOKEN }}
107+
path: comfyui-fork
108+
fetch-depth: 1
109+
110+
- name: Create branch and update requirements.txt
111+
if: steps.version_check.outputs.changed == 'true'
112+
working-directory: comfyui-fork
113+
run: |
114+
# Configure git
115+
git config user.name "github-actions[bot]"
116+
git config user.email "github-actions[bot]@users.noreply.github.com"
117+
118+
# Create branch with version and timestamp
119+
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
120+
VERSION="${{ steps.current_version.outputs.version }}"
121+
BRANCH_NAME="update-docs-${VERSION}-${TIMESTAMP}"
122+
123+
git checkout -b $BRANCH_NAME
124+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
125+
echo "🌿 Created branch: $BRANCH_NAME"
126+
127+
# Update requirements.txt
128+
if [ -f requirements.txt ]; then
129+
sed -i "s/comfyui-embedded-docs==.*/comfyui-embedded-docs==${VERSION}/" requirements.txt
130+
echo "✅ Updated requirements.txt to version ${VERSION}"
131+
git add requirements.txt
132+
git commit -m "chore: update embedded-docs to v${VERSION}"
133+
else
134+
echo "⚠️ Warning: requirements.txt not found!"
135+
exit 1
136+
fi
137+
138+
- name: Push to fork
139+
if: steps.version_check.outputs.changed == 'true'
140+
working-directory: comfyui-fork
141+
run: |
142+
git push origin ${{ env.BRANCH_NAME }}
143+
echo "✅ Pushed branch ${{ env.BRANCH_NAME }} to fork"
144+
145+
- name: Create draft PR
146+
if: steps.version_check.outputs.changed == 'true'
147+
env:
148+
GH_TOKEN: ${{ secrets.COMFYUI_FORK_TOKEN }}
149+
run: |
150+
VERSION="${{ steps.current_version.outputs.version }}"
151+
CHANGELOG_FILE="${{ steps.changelog.outputs.changelog_file }}"
152+
153+
# Create PR from fork to upstream
154+
PR_URL=$(gh pr create \
155+
--repo comfyanonymous/ComfyUI \
156+
--base master \
157+
--head comfyui-wiki:${{ env.BRANCH_NAME }} \
158+
--title "Update docs to v${VERSION}" \
159+
--body-file "$CHANGELOG_FILE" \
160+
--draft)
161+
162+
echo "✅ Draft PR created: $PR_URL"
163+
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
164+
165+
- name: Send notification
166+
if: steps.version_check.outputs.changed == 'true'
167+
run: |
168+
VERSION="${{ steps.current_version.outputs.version }}"
169+
echo "🎉 Successfully created draft PR for version ${VERSION}"
170+
echo "📝 PR URL: ${{ env.PR_URL }}"
171+
echo ""
172+
echo "👉 You will receive a GitHub notification for the draft PR"
173+
echo "📧 Check your GitHub notifications at: https://github.com/notifications"
174+

0 commit comments

Comments
 (0)