[devex] Update hotfix release command to work with new automated backporting process (#5271)

* Update hotfix release command for modern automated backport workflow

- Add Step 0 to check automated backport status first
- Emphasize this command is fallback when automation fails
- Add critical draft release publishing step (uncheck 'Set as latest')
- Add ComfyUI requirements.txt PR creation with exact template
- Update workflow context for modern automated backports

* Restructure hotfix release command for modern workflow

- Add clear process overview and context at top
- Step 1: Try automated backports first (via labels)
- Fallback to manual cherry-picking only if automation fails
- Add critical draft release publishing step (uncheck 'Set as latest')
- Add ComfyUI requirements.txt PR creation with exact template
- Remove time estimates and reorganize for clarity
- Update step numbering and cross-references

* Enable backport automation for already-merged PRs

- Add 'labeled' trigger to backport workflow
- Allow backport automation when needs-backport label is added to merged PRs
- Supports hotfix workflow where labels are added retroactively
- Maintains existing behavior for PRs merged with labels already present

* Prevent duplicate backport triggers with idempotency check

- Add check for existing backport PRs before starting backport process
- Skip backport work if PRs already exist for the same PR number
- Prevents double execution when both 'labeled' and 'closed' events trigger
- Maintains workflow reliability and avoids duplicate backport PRs

* Add smart backport detection to hotfix command

- Check for existing automated backport PRs and their status
- Path A: Skip to version bump if backports already merged
- Path B: Guide user to merge pending backport PRs first
- Path C: Fall back to manual cherry-picking if no/failed automation
- Add clear workflow path documentation for different scenarios

* Add automated fork handling for ComfyUI requirements.txt PRs

- Check if fork exists, create if needed
- Clone fork to local ComfyUI-fork directory
- Create branch, update requirements.txt with sed
- Create PR from fork using gh CLI with exact template format
- Handle both new and existing fork scenarios
- Keep fork directory for future updates

* [style] improve backport workflow logging and structure

- Change ::notice to ::warning for existing backports per @DrJKL's feedback
- Refactor conditional to use guard clause pattern per @DrJKL's suggestion
- Improves readability and follows conventional shell scripting patterns

Addresses @DrJKL's review comments in PR #5271
This commit is contained in:
Christian Byrne
2025-09-05 21:11:46 -07:00
committed by GitHub
parent 687580e155
commit bd299b8210
2 changed files with 218 additions and 36 deletions

View File

@@ -2,7 +2,7 @@ name: Auto Backport
on:
pull_request_target:
types: [closed]
types: [closed, labeled]
branches: [main]
jobs:
@@ -25,7 +25,27 @@ jobs:
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Check if backports already exist
id: check-existing
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
# Check for existing backport PRs for this PR number
EXISTING_BACKPORTS=$(gh pr list --state all --search "backport-${PR_NUMBER}-to" --json title,headRefName,baseRefName | jq -r '.[].headRefName')
if [ -z "$EXISTING_BACKPORTS" ]; then
echo "skip=false" >> $GITHUB_OUTPUT
return
fi
echo "Found existing backport PRs:"
echo "$EXISTING_BACKPORTS"
echo "skip=true" >> $GITHUB_OUTPUT
echo "::warning::Backport PRs already exist for PR #${PR_NUMBER}, skipping to avoid duplicates"
- name: Extract version labels
if: steps.check-existing.outputs.skip != 'true'
id: versions
run: |
# Extract version labels (e.g., "1.24", "1.22")
@@ -52,6 +72,7 @@ jobs:
echo "Found version labels: ${VERSIONS}"
- name: Backport commits
if: steps.check-existing.outputs.skip != 'true'
id: backport
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
@@ -109,7 +130,7 @@ jobs:
fi
- name: Create PR for each successful backport
if: steps.backport.outputs.success
if: steps.check-existing.outputs.skip != 'true' && steps.backport.outputs.success
env:
GH_TOKEN: ${{ secrets.PR_GH_TOKEN }}
run: |
@@ -141,7 +162,7 @@ jobs:
done
- name: Comment on failures
if: failure() && steps.backport.outputs.failed
if: steps.check-existing.outputs.skip != 'true' && failure() && steps.backport.outputs.failed
env:
GH_TOKEN: ${{ github.token }}
run: |