Skip to content

fix(fix_custom_translations): permissions #5

fix(fix_custom_translations): permissions

fix(fix_custom_translations): permissions #5

name: Update Locales for given custom node repository
on:
push:
env:
owner: huchenlei
repository: ComfyUI-IC-Light-Native
fork_owner: comfy-pr-bot
jobs:
update-locales:
runs-on: ubuntu-latest
permissions:
contents: write # To push a branch
pull-requests: write # To create a PR from that branch
# - [git - Permission denied to github-actions[bot] despite having PAT - Stack Overflow]( https://stackoverflow.com/questions/74740868/permission-denied-to-github-actionsbot-despite-having-pat )
steps:
- name: Checkout ComfyUI
uses: actions/checkout@v4
with:
repository: 'comfyanonymous/ComfyUI'
path: 'ComfyUI'
ref: master
- name: Checkout ComfyUI_frontend
uses: actions/checkout@v4
with:
repository: 'Comfy-Org/ComfyUI_frontend'
path: 'ComfyUI_frontend'
- name: Checkout ComfyUI_devtools
uses: actions/checkout@v4
with:
repository: 'Comfy-Org/ComfyUI_devtools'
path: 'ComfyUI/custom_nodes/ComfyUI_devtools'
- name: Checkout custom node repository
uses: actions/checkout@v4
with:
repository: ${{ env.owner }}/${{ env.repository }}
path: 'ComfyUI/custom_nodes/${{ env.repository }}'
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install ComfyUI requirements
run: |
python -m pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install -r requirements.txt
pip install wait-for-it
shell: bash
working-directory: ComfyUI
- name: Install custom node requirements
run: |
if [ -f "requirements.txt" ]; then
pip install -r requirements.txt
fi
shell: bash
working-directory: ComfyUI/custom_nodes/${{ env.repository }}
- name: Build & Install ComfyUI_frontend
run: |
npm ci
npm run build
rm -rf ../ComfyUI/web/*
mv dist/* ../ComfyUI/web/
shell: bash
working-directory: ComfyUI_frontend
- name: Start ComfyUI server
run: |
python main.py --cpu --multi-user &
wait-for-it --service 127.0.0.1:8188 -t 600
working-directory: ComfyUI
shell: bash
- 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: Capture base i18n
run: npx tsx scripts/diff-i18n capture
working-directory: ComfyUI_frontend
- name: Update en.json
run: npm run collect-i18n
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: Diff base vs updated i18n
run: npx tsx scripts/diff-i18n diff
working-directory: ComfyUI_frontend
- name: Update i18n in custom node repository
run: |
LOCALE_DIR=ComfyUI/custom_nodes/${{ env.repository }}/locales/
install -d "$LOCALE_DIR"
cp -rf ComfyUI_frontend/temp/diff/* "$LOCALE_DIR"
- name: Check and create fork of custom node repository
run: |
# Try to fork the repository
gh repo fork ${{ env.owner }}/${{ env.repository }} --clone=false || {
echo "Fork failed - repository might already be forked"
# Exit 0 to prevent the workflow from failing
exit 0
}
# Enable workflows on the forked repository
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
"/repos/${{ env.fork_owner }}/${{ env.repository }}/actions/permissions/workflow" \
-F can_approve_pull_request_reviews=true \
-F default_workflow_permissions="write" \
-F enabled=true
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Commit and push changes
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
# Configure the remote with token
git remote add pr "https://x-access-token:[email protected]/${{ env.fork_owner }}/${{ env.repository }}.git"
git remote -v
# Create and switch to new branch
git checkout -b update-locales
# Stage and commit changes
git add -A
git commit -m "Update locales"
# Force push to create the branch
echo "Pushing changes to ${{ env.fork_owner }}/${{ env.repository }}"
git push -f pr update-locales ||
git push -f https://x-access-token:[email protected]/${{ env.fork_owner }}/${{ env.repository }}.git update-locales
# Create PR using gh cli
gh pr create --title "Update locales for ${{ env.repository }}" --repo ${{ env.owner }}/${{ env.repository }} --head ${{ env.fork_owner }}:update-locales
working-directory: ComfyUI/custom_nodes/${{ env.repository }}
env:
GH_TOKEN_PR: ${{ secrets.GH_TOKEN_PR }}