mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 23:50:08 +00:00
[feat] Merge commit-back workflows into unified auto-fix-and-update workflow
- Combines lint-and-format and locale update workflows to avoid git conflicts - Uses stefanzweifel/git-auto-commit-action@v5 for reliable commits - Includes proper permissions (contents: write, pull-requests: write, issues: write) - Handles both main repo PRs (with auto-commit) and fork PRs (with guidance comments) - Updates locales only when relevant code changes are detected - Single commit strategy prevents conflicts between different auto-fix operations Resolves conflicts mentioned in PR #4940 comments where multiple commit-back workflows would interfere with each other. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
184
.github/workflows/auto-fix-and-update.yaml
vendored
Normal file
184
.github/workflows/auto-fix-and-update.yaml
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
name: Auto-fix and Update
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches-ignore: [wip/*, draft/*, temp/*]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
auto-fix-and-update:
|
||||
# Only run on PRs from the same repository (not forks) to avoid permission issues
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout PR
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
# Step 1: Run lint and format fixes
|
||||
- name: Run ESLint with auto-fix
|
||||
run: npm run lint:fix
|
||||
|
||||
- name: Run Prettier with auto-format
|
||||
run: npm run format
|
||||
|
||||
# Step 2: Update locales (only if there are relevant changes)
|
||||
- name: Check if locale updates needed
|
||||
id: check-locale-changes
|
||||
run: |
|
||||
# Check if there are changes to files that would affect locales
|
||||
if git diff --name-only origin/${{ github.base_ref }}..HEAD | grep -E '\.(vue|ts|tsx)$' | grep -v test | head -1; then
|
||||
echo "locale_updates_needed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "locale_updates_needed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Install Playwright Browsers
|
||||
if: steps.check-locale-changes.outputs.locale_updates_needed == 'true'
|
||||
run: npx playwright install chromium --with-deps
|
||||
|
||||
- name: Start dev server
|
||||
if: steps.check-locale-changes.outputs.locale_updates_needed == 'true'
|
||||
run: npm run dev:electron &
|
||||
|
||||
- name: Update en.json
|
||||
if: steps.check-locale-changes.outputs.locale_updates_needed == 'true'
|
||||
run: npm run collect-i18n -- scripts/collect-i18n-general.ts
|
||||
env:
|
||||
PLAYWRIGHT_TEST_URL: http://localhost:5173
|
||||
|
||||
- name: Update translations
|
||||
if: steps.check-locale-changes.outputs.locale_updates_needed == 'true'
|
||||
run: npm run locale
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
|
||||
# Step 3: Check for any changes from both lint-format and locale updates
|
||||
- name: Check for changes
|
||||
id: verify-changed-files
|
||||
run: |
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "changed=true" >> $GITHUB_OUTPUT
|
||||
# Show what changed for debugging
|
||||
echo "Changed files:"
|
||||
git status --porcelain
|
||||
else
|
||||
echo "changed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
# Step 4: Commit all changes in a single commit
|
||||
- name: Commit auto-fixes and locale updates
|
||||
if: steps.verify-changed-files.outputs.changed == 'true'
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: '[auto-fix] Apply ESLint, Prettier fixes and update locales'
|
||||
file_pattern: '.'
|
||||
|
||||
# Step 5: Run final validation
|
||||
- name: Final validation
|
||||
run: |
|
||||
npm run lint
|
||||
npm run format:check
|
||||
npm run knip
|
||||
|
||||
# Step 6: Comment on PR about what was fixed
|
||||
- name: Comment on PR about auto-fixes
|
||||
if: steps.verify-changed-files.outputs.changed == 'true'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
let changes = [];
|
||||
if ('${{ steps.check-locale-changes.outputs.locale_updates_needed }}' === 'true') {
|
||||
changes.push('Locale updates');
|
||||
}
|
||||
// Always include lint/format as we ran them
|
||||
changes.push('ESLint auto-fixes', 'Prettier formatting');
|
||||
|
||||
const changesText = changes.join('\n- ');
|
||||
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: `## 🔧 Auto-fixes Applied
|
||||
|
||||
This PR has been automatically updated with the following changes:
|
||||
|
||||
- ${changesText}
|
||||
|
||||
**⚠️ Important**: Your local branch is now behind. Run \`git pull\` before making additional changes to avoid conflicts.`
|
||||
});
|
||||
|
||||
# Separate job for fork PRs that can't auto-commit
|
||||
fork-pr-check:
|
||||
if: github.event.pull_request.head.repo.full_name != github.repository
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout PR
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Check linting and formatting
|
||||
id: check-lint-format
|
||||
run: |
|
||||
# Run checks and capture exit codes
|
||||
npm run lint || echo "lint_failed=true" >> $GITHUB_OUTPUT
|
||||
npm run format:check || echo "format_failed=true" >> $GITHUB_OUTPUT
|
||||
npm run knip || echo "knip_failed=true" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Comment on fork PR about manual fixes needed
|
||||
if: steps.check-lint-format.outputs.lint_failed == 'true' || steps.check-lint-format.outputs.format_failed == 'true' || steps.check-lint-format.outputs.knip_failed == 'true'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: `## ⚠️ Linting/Formatting Issues Found
|
||||
|
||||
This PR has linting or formatting issues that need to be fixed.
|
||||
|
||||
**Since this PR is from a fork, auto-fix cannot be applied automatically.**
|
||||
|
||||
### Option 1: Set up pre-commit hooks (recommended)
|
||||
Run this once to automatically format code on every commit:
|
||||
\`\`\`bash
|
||||
npm run prepare
|
||||
\`\`\`
|
||||
|
||||
### Option 2: Fix manually
|
||||
Run these commands and push the changes:
|
||||
\`\`\`bash
|
||||
npm run lint:fix
|
||||
npm run format
|
||||
\`\`\`
|
||||
|
||||
See [CONTRIBUTING.md](https://github.com/Comfy-Org/ComfyUI_frontend/blob/main/CONTRIBUTING.md#git-pre-commit-hooks) for more details.`
|
||||
});
|
||||
43
.github/workflows/i18n.yaml
vendored
43
.github/workflows/i18n.yaml
vendored
@@ -1,43 +0,0 @@
|
||||
name: Update Locales
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master, dev* ]
|
||||
paths-ignore:
|
||||
- '.github/**'
|
||||
- '.husky/**'
|
||||
- '.vscode/**'
|
||||
- 'browser_tests/**'
|
||||
- 'tests-ui/**'
|
||||
|
||||
jobs:
|
||||
update-locales:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: Comfy-Org/ComfyUI_frontend_setup_action@v2.3
|
||||
- name: Install Playwright Browsers
|
||||
run: npx playwright install chromium --with-deps
|
||||
working-directory: ComfyUI_frontend
|
||||
- name: Start dev server
|
||||
# Run electron dev server as it is a superset of the web dev server
|
||||
# We do want electron specific UIs to be translated.
|
||||
run: npm run dev:electron &
|
||||
working-directory: ComfyUI_frontend
|
||||
- name: Update en.json
|
||||
run: npm run collect-i18n -- scripts/collect-i18n-general.ts
|
||||
env:
|
||||
PLAYWRIGHT_TEST_URL: http://localhost:5173
|
||||
working-directory: ComfyUI_frontend
|
||||
- name: Update translations
|
||||
run: npm run locale
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
working-directory: ComfyUI_frontend
|
||||
- name: Commit updated locales
|
||||
run: |
|
||||
git config --global user.name 'github-actions'
|
||||
git config --global user.email 'github-actions@github.com'
|
||||
git add src/locales/
|
||||
git diff --staged --quiet || git commit -m "Update locales [skip ci]"
|
||||
git push origin HEAD
|
||||
working-directory: ComfyUI_frontend
|
||||
82
.github/workflows/lint-and-format.yaml
vendored
82
.github/workflows/lint-and-format.yaml
vendored
@@ -1,82 +0,0 @@
|
||||
name: Lint and Format
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches-ignore: [wip/*, draft/*, temp/*]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
lint-and-format:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout PR
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Run ESLint with auto-fix
|
||||
run: npm run lint:fix
|
||||
|
||||
- name: Run Prettier with auto-format
|
||||
run: npm run format
|
||||
|
||||
- name: Check for changes
|
||||
id: verify-changed-files
|
||||
run: |
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "changed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "changed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
# commit prettier fixed code
|
||||
- name: Commit changes
|
||||
if: steps.verify-changed-files.outputs.changed == 'true' && github.event.pull_request.head.repo.full_name == github.repository
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: '[auto-fix] Apply ESLint and Prettier fix'
|
||||
|
||||
- name: Final validation
|
||||
run: |
|
||||
npm run lint
|
||||
npm run format:check
|
||||
npm run knip
|
||||
|
||||
- name: Comment on PR about auto-fix
|
||||
if: steps.verify-changed-files.outputs.changed == 'true' && github.event.pull_request.head.repo.full_name == github.repository
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: '## 🔧 Auto-fixes Applied\n\nThis PR has been automatically updated to fix linting and formatting issues.\n\n**⚠️ Important**: Your local branch is now behind. Run `git pull` before making additional changes to avoid conflicts.\n\n### Changes made:\n- ESLint auto-fixes\n- Prettier formatting'
|
||||
})
|
||||
|
||||
- name: Comment on PR about manual fix needed
|
||||
if: steps.verify-changed-files.outputs.changed == 'true' && github.event.pull_request.head.repo.full_name != github.repository
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: '## ⚠️ Linting/Formatting Issues Found\n\nThis PR has linting or formatting issues that need to be fixed.\n\n**Since this PR is from a fork, auto-fix cannot be applied automatically.**\n\n### Option 1: Set up pre-commit hooks (recommended)\nRun this once to automatically format code on every commit:\n```bash\nnpm run prepare\n```\n\n### Option 2: Fix manually\nRun these commands and push the changes:\n```bash\nnpm run lint:fix\nnpm run format\n```\n\nSee [CONTRIBUTING.md](https://github.com/Comfy-Org/ComfyUI_frontend/blob/main/CONTRIBUTING.md#git-pre-commit-hooks) for more details.'
|
||||
})
|
||||
Reference in New Issue
Block a user