Skip to content

Update changelog with comfyui v0.3.41 #142

Update changelog with comfyui v0.3.41

Update changelog with comfyui v0.3.41 #142

name: Chinese Translation Sync Check
on:
pull_request:
branches:
- main
paths:
- '**/*.mdx'
- '!zh-CN/**/*.mdx'
- '!snippets/zh/**/*.mdx'
jobs:
check-zh-cn-translations:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Check changed MDX files have zh-CN equivalents and check for moved files
id: check-translations
run: |
# Get list of changed MDX files
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep "\.mdx$" | grep -v "^zh-CN/" | grep -v "^snippets/zh/" || true)
# Get list of deleted MDX files (potentially moved)
DELETED_FILES=$(git diff --name-only --diff-filter=D ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep "\.mdx$" | grep -v "^zh-CN/" | grep -v "^snippets/zh/" || true)
# Get list of added MDX files (potentially destinations of moves)
ADDED_FILES=$(git diff --name-only --diff-filter=A ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep "\.mdx$" | grep -v "^zh-CN/" | grep -v "^snippets/zh/" || true)
# Exit if no MDX files were changed, deleted or added
if [ -z "$CHANGED_FILES" ] && [ -z "$DELETED_FILES" ] && [ -z "$ADDED_FILES" ]; then
echo "No MDX files changed outside of zh-CN and snippets/zh directories. Skipping check."
exit 0
fi
# Check for moved files - these would be deleted and added in the same PR
MOVED_FILES=""
MOVE_DESTINATIONS=""
if [ ! -z "$DELETED_FILES" ] && [ ! -z "$ADDED_FILES" ]; then
echo "Potential file moves detected:"
echo "------------------------"
echo "Deleted files:"
echo "$DELETED_FILES"
echo "------------------------"
echo "Added files:"
echo "$ADDED_FILES"
echo "------------------------"
# Check if redirects are added in docs.json for deleted files
DOCS_JSON_CHANGED=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -q "docs.json" && echo "true" || echo "false")
if [ "$DOCS_JSON_CHANGED" = "false" ]; then
echo "⚠️ docs.json was not modified - if files were moved, redirects should be added."
fi
# Check docs.json content for redirects if it was changed
if [ "$DOCS_JSON_CHANGED" = "true" ]; then
echo "Checking docs.json for redirects..."
# Get the current content of docs.json
DOCS_JSON_CONTENT=$(cat docs.json)
for deleted_file in $DELETED_FILES; do
# Remove .mdx extension
SOURCE_PATH="${deleted_file%.mdx}"
# Check if a redirect exists for this path
if echo "$DOCS_JSON_CONTENT" | grep -q "\"source\": \"/${SOURCE_PATH}\"" || echo "$DOCS_JSON_CONTENT" | grep -q "\"source\": \"${SOURCE_PATH}\""; then
echo "✅ Found redirect for moved file: ${deleted_file}"
else
echo "❌ Missing redirect in docs.json for: ${deleted_file}"
MOVED_FILES="$MOVED_FILES ${deleted_file}"
fi
done
else
# If docs.json wasn't changed, all deleted files are suspect
MOVED_FILES="$DELETED_FILES"
fi
fi
echo "Changed MDX files outside zh-CN directory:"
echo "$CHANGED_FILES"
echo "------------------------"
# Check each file for corresponding zh-CN updates
MISSING_TRANSLATIONS=""
for file in $CHANGED_FILES; do
# Determine the corresponding zh-CN path based on whether it's a snippet or not
if [[ $file == snippets/* ]]; then
# For snippets, the Chinese version should be in snippets/zh/
zh_file="${file/snippets\//snippets\/zh\/}"
else
# For regular docs, the Chinese version should be in zh-CN/
zh_file="zh-CN/${file}"
fi
# Check if the corresponding zh-CN file was also modified
if git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -q "^${zh_file}$"; then
echo "✅ Found corresponding change: ${zh_file}"
else
# Check if the zh-CN file exists at all
if [ -f "${zh_file}" ]; then
echo "❌ Missing update to existing file: ${zh_file}"
MISSING_TRANSLATIONS="$MISSING_TRANSLATIONS ${zh_file}"
else
echo "❌ Missing equivalent file: ${zh_file}"
MISSING_TRANSLATIONS="$MISSING_TRANSLATIONS ${zh_file}"
fi
fi
done
# For added files, check corresponding zh-CN files
for file in $ADDED_FILES; do
# Determine the corresponding zh-CN path based on whether it's a snippet or not
if [[ $file == snippets/* ]]; then
# For snippets, the Chinese version should be in snippets/zh/
zh_file="${file/snippets\//snippets\/zh\/}"
else
# For regular docs, the Chinese version should be in zh-CN/
zh_file="zh-CN/${file}"
fi
# Check if the corresponding zh-CN file was also added
if git diff --name-only --diff-filter=A ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -q "^${zh_file}$"; then
echo "✅ Found corresponding added file: ${zh_file}"
else
echo "❌ Missing equivalent for added file: ${zh_file}"
MISSING_TRANSLATIONS="$MISSING_TRANSLATIONS ${zh_file}"
fi
done
# Determine if we need to fail the check
SHOULD_FAIL="false"
# Check for missing translations
if [ "$MISSING_TRANSLATIONS" != "" ]; then
SHOULD_FAIL="true"
echo "------------------------"
echo "❌ The following translations need to be updated:"
for missing in $MISSING_TRANSLATIONS; do
echo "- $missing"
done
fi
# Check for moved files without redirects
if [ "$MOVED_FILES" != "" ]; then
SHOULD_FAIL="true"
echo "------------------------"
echo "❌ The following files were moved but missing redirects in docs.json:"
for moved in $MOVED_FILES; do
echo "- $moved"
done
echo "------------------------"
echo "Please add redirects in docs.json for moved files using the format:"
echo '{"redirects":[{"source":"/path/to/old-file","destination":"/path/to/new-file"}]}'
echo "------------------------"
fi
# Exit with error if we found issues
if [ "$SHOULD_FAIL" = "true" ]; then
echo "------------------------"
echo "Please fix the issues above before merging this PR."
exit 1
else
echo "------------------------"
echo "✅ All checks passed!"
fi