Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 199 additions & 0 deletions .github/workflows/AUTO_PR_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
# Auto PR to ComfyUI Setup Guide

This document explains how to set up and use the automated PR workflow that syncs `embedded-docs` version updates to the ComfyUI repository.

## 🎯 What This Workflow Does

When you bump the version in `pyproject.toml` on the `main` branch, this workflow automatically:

1. ✅ Detects the version change
2. ✅ Generates a changelog from commits and merged PRs
3. ✅ Updates `requirements.txt` in your ComfyUI fork
4. ✅ Creates a new branch with format: `update-docs-{VERSION}-{TIMESTAMP}`
5. ✅ Submits a **draft PR** to `comfyanonymous/ComfyUI`
6. ✅ Sends you a GitHub notification

## 🔧 Setup Instructions

### 1. Create a GitHub Personal Access Token (PAT)

You need a PAT with permissions to:
- Push to `comfyui-wiki/ComfyUI` (your fork)
- Create PRs on `comfyanonymous/ComfyUI` (target repository)

**Steps:**
1. Go to: https://github.com/settings/tokens/new
2. Select **Fine-grained tokens** (recommended) or **Classic token**
3. Configure the token:
- **Name**: `ComfyUI Auto PR Token`
- **Expiration**: Choose based on your preference
- **Repository access**:
- Select "Only select repositories"
- Add: `comfyui-wiki/ComfyUI`
- **Permissions**:
- Repository permissions:
- Contents: Read and write
- Pull requests: Read and write
- Metadata: Read-only (automatic)

4. Click **Generate token** and copy it immediately (you won't see it again!)

### 2. Add the Token to Repository Secrets

1. Go to your `embedded-docs` repository
2. Navigate to: **Settings** → **Secrets and variables** → **Actions**
3. Click **New repository secret**
4. Add the secret:
- **Name**: `COMFYUI_FORK_TOKEN`
- **Value**: Paste your PAT from step 1
5. Click **Add secret**

### 3. Verify the Workflow File

The workflow file is located at: `.github/workflows/auto-pr-to-comfyui.yml`

Make sure these values are correct:
- Fork repository: `comfyui-wiki/ComfyUI`
- Target repository: `comfyanonymous/ComfyUI`
- Target branch: `master`
- Requirements file: `requirements.txt`

## 📋 How to Use

### Normal Workflow

1. Make your changes to documentation
2. Update the version in `pyproject.toml`
3. Commit and push to `main` branch
4. The workflow triggers automatically
5. You'll receive a GitHub notification when the draft PR is created
6. Review the draft PR at: https://github.com/comfyanonymous/ComfyUI/pulls

### Manual Trigger

Currently, the workflow only triggers on version changes. If you need to manually trigger it, you can add this to the workflow:

```yaml
on:
workflow_dispatch: # Add this line
push:
branches: [main]
paths:
- "pyproject.toml"
```

## 📬 Notifications

You will automatically receive GitHub notifications when:
- ✅ A draft PR is created
- ✅ Someone comments on the PR
- ✅ The PR status changes

**To ensure you receive notifications:**
1. Go to: https://github.com/settings/notifications
2. Make sure these are enabled:
- ✅ Email notifications
- ✅ Pull requests
- ✅ Participating (for PRs you created)

## 🔍 Troubleshooting

### Problem: Workflow doesn't trigger

**Solutions:**
- Check that the file changed is exactly `pyproject.toml`
- Verify you pushed to the `main` branch
- Check workflow runs at: `https://github.com/Comfy-Org/embedded-docs/actions`

### Problem: Authentication failed

**Solutions:**
- Verify the `COMFYUI_FORK_TOKEN` secret is set correctly
- Check that your PAT hasn't expired
- Ensure the PAT has the correct permissions

### Problem: PR creation fails

**Solutions:**
- Verify that `comfyui-wiki/ComfyUI` fork exists
- Check that the fork is up to date with upstream
- Ensure `requirements.txt` exists in the fork

### Problem: No notifications received

**Solutions:**
- Check your GitHub notification settings
- Look at: https://github.com/notifications
- Verify email settings in your GitHub profile

## 📝 PR Content Structure

The generated draft PR includes:

```markdown
## Update embedded docs to v{VERSION}

### 📦 Package Information
- **PyPI**: https://pypi.org/project/comfyui-embedded-docs/{VERSION}/
- **Release**: https://github.com/Comfy-Org/embedded-docs/releases/tag/v{VERSION}

### 📝 Changes since v{PREV_VERSION}

#### Merged Pull Requests
- PR #123: Add documentation for new nodes
- PR #124: Fix typos in CLIPLoader docs

#### Commits
- abc1234: Update Spanish translations
- def5678: Add images for flux nodes

---
*This is an automated draft PR created by the embedded-docs sync workflow.*
```

## 🔐 Security Notes

- ⚠️ **Never commit tokens directly** to the repository
- ✅ Always use GitHub Secrets for sensitive data
- ✅ Use fine-grained tokens with minimal required permissions
- ✅ Regularly rotate your tokens (every 6-12 months)
- ✅ Audit token usage in GitHub settings

## 📊 Workflow Visualization

```
Version Bump in pyproject.toml
Workflow Triggers
Extract Version Info
Generate Changelog
Clone ComfyUI Fork
Update requirements.txt
Create New Branch
Push to Fork
Create Draft PR
GitHub Notification Sent
```

## 🆘 Support

If you encounter issues:
1. Check the workflow logs in GitHub Actions
2. Verify all settings in this guide
3. Test with a minor version bump first (e.g., 0.3.0 → 0.3.1)

## 📚 Related Files

- Workflow: `.github/workflows/auto-pr-to-comfyui.yml`
- Publish workflow: `.github/workflows/publish.yml`
- Version file: `pyproject.toml`
- Target file: `requirements.txt` (in ComfyUI fork)

174 changes: 174 additions & 0 deletions .github/workflows/auto-pr-to-comfyui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
name: Auto PR to ComfyUI on Version Bump

on:
push:
branches: [main]
paths:
- "pyproject.toml"

jobs:
create-pr:
runs-on: ubuntu-latest

steps:
- name: Checkout embedded-docs repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # Get full history for changelog generation

- name: Get current version
id: current_version
run: |
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Current version: $VERSION"

- name: Get previous version
id: previous_version
run: |
# Get the previous version tag
PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
if [ -z "$PREV_TAG" ]; then
echo "version=0.0.0" >> $GITHUB_OUTPUT
echo "No previous version tag found, using 0.0.0"
else
PREV_VERSION=${PREV_TAG#v}
echo "version=$PREV_VERSION" >> $GITHUB_OUTPUT
echo "tag=$PREV_TAG" >> $GITHUB_OUTPUT
echo "Previous version: $PREV_VERSION (tag: $PREV_TAG)"
fi

- name: Check if version changed
id: version_check
run: |
CURRENT="${{ steps.current_version.outputs.version }}"
PREVIOUS="${{ steps.previous_version.outputs.version }}"

if [ "$CURRENT" != "$PREVIOUS" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "✅ Version bumped from $PREVIOUS to $CURRENT"
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "ℹ️ No version change detected"
fi

- name: Generate changelog
id: changelog
if: steps.version_check.outputs.changed == 'true'
run: |
PREV_TAG="${{ steps.previous_version.outputs.tag }}"
CURRENT_VERSION="${{ steps.current_version.outputs.version }}"

# Create changelog file
CHANGELOG_FILE="pr_changelog.md"

echo "## Update embedded docs to v${CURRENT_VERSION}" > $CHANGELOG_FILE
echo "" >> $CHANGELOG_FILE
echo "### 📦 Package Information" >> $CHANGELOG_FILE
echo "- **PyPI**: https://pypi.org/project/comfyui-embedded-docs/${CURRENT_VERSION}/" >> $CHANGELOG_FILE
echo "- **Release**: https://github.com/Comfy-Org/embedded-docs/releases/tag/v${CURRENT_VERSION}" >> $CHANGELOG_FILE
echo "" >> $CHANGELOG_FILE

if [ -n "$PREV_TAG" ]; then
echo "### 📝 Changes since ${PREV_TAG}" >> $CHANGELOG_FILE
echo "" >> $CHANGELOG_FILE

# Get merged PRs
echo "#### Merged Pull Requests" >> $CHANGELOG_FILE
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
echo "" >> $CHANGELOG_FILE

# Get commits (excluding merge commits)
echo "#### Commits" >> $CHANGELOG_FILE
git log ${PREV_TAG}..HEAD --no-merges --pretty=format:"- %s (%h)" >> $CHANGELOG_FILE
echo "" >> $CHANGELOG_FILE
else
echo "### 📝 Initial Release" >> $CHANGELOG_FILE
echo "" >> $CHANGELOG_FILE
echo "This is the initial automated sync of the embedded-docs package." >> $CHANGELOG_FILE
echo "" >> $CHANGELOG_FILE
fi

echo "" >> $CHANGELOG_FILE
echo "---" >> $CHANGELOG_FILE
echo "*This is an automated draft PR created by the embedded-docs sync workflow.*" >> $CHANGELOG_FILE

echo "changelog_file=$CHANGELOG_FILE" >> $GITHUB_OUTPUT

echo "📄 Generated changelog:"
cat $CHANGELOG_FILE

- name: Checkout ComfyUI fork
if: steps.version_check.outputs.changed == 'true'
uses: actions/checkout@v4
with:
repository: 'comfyui-wiki/ComfyUI'
token: ${{ secrets.COMFYUI_FORK_TOKEN }}
path: comfyui-fork
fetch-depth: 1

- name: Create branch and update requirements.txt
if: steps.version_check.outputs.changed == 'true'
working-directory: comfyui-fork
run: |
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Create branch with version and timestamp
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
VERSION="${{ steps.current_version.outputs.version }}"
BRANCH_NAME="update-docs-${VERSION}-${TIMESTAMP}"

git checkout -b $BRANCH_NAME
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
echo "🌿 Created branch: $BRANCH_NAME"

# Update requirements.txt
if [ -f requirements.txt ]; then
sed -i "s/comfyui-embedded-docs==.*/comfyui-embedded-docs==${VERSION}/" requirements.txt
echo "✅ Updated requirements.txt to version ${VERSION}"
git add requirements.txt
git commit -m "chore: update embedded-docs to v${VERSION}"
else
echo "⚠️ Warning: requirements.txt not found!"
exit 1
fi

- name: Push to fork
if: steps.version_check.outputs.changed == 'true'
working-directory: comfyui-fork
run: |
git push origin ${{ env.BRANCH_NAME }}
echo "✅ Pushed branch ${{ env.BRANCH_NAME }} to fork"

- name: Create draft PR
if: steps.version_check.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.COMFYUI_FORK_TOKEN }}
run: |
VERSION="${{ steps.current_version.outputs.version }}"
CHANGELOG_FILE="${{ steps.changelog.outputs.changelog_file }}"

# Create PR from fork to upstream
PR_URL=$(gh pr create \
--repo comfyanonymous/ComfyUI \
--base master \
--head comfyui-wiki:${{ env.BRANCH_NAME }} \
--title "Update docs to v${VERSION}" \
--body-file "$CHANGELOG_FILE" \
--draft)

echo "✅ Draft PR created: $PR_URL"
echo "PR_URL=$PR_URL" >> $GITHUB_ENV

- name: Send notification
if: steps.version_check.outputs.changed == 'true'
run: |
VERSION="${{ steps.current_version.outputs.version }}"
echo "🎉 Successfully created draft PR for version ${VERSION}"
echo "📝 PR URL: ${{ env.PR_URL }}"
echo ""
echo "👉 You will receive a GitHub notification for the draft PR"
echo "📧 Check your GitHub notifications at: https://github.com/notifications"

Loading