1
0
Fork 0
mirror of https://github.com/elementor/hello-theme.git synced 2026-07-27 14:01:37 +08:00
hello-theme/.github/workflows/build-theme/action.yml
Workflow config file is invalid. Please check your config file: Line: 4 Column 1: Unknown Property inputs Line: 13 Column 1: Unknown Property runs Forgejo Actions YAML Schema validation error

119 lines
4.3 KiB
YAML

name: Build Hello Theme
description: Build Hello Theme with specified version
inputs:
PACKAGE_VERSION:
description: 'The package version to build (e.g. 3.4.4)'
required: true
BUILD_SCRIPT_PATH:
description: 'Path to build script'
required: false
default: "npm run build:prod"
runs:
using: "composite"
steps:
- name: Install npm dependencies
shell: bash
run: |
export PUPPETEER_SKIP_DOWNLOAD=true
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
# Enhanced retry logic for npm ci with registry fallbacks and cache clearing
for i in {1..3}; do
echo "🔄 Attempt $i/3: Installing npm dependencies..."
# Try npm ci first
if npm ci --prefer-offline --no-audit --no-fund --silent; then
echo "✅ npm ci succeeded on attempt $i"
break
else
echo "❌ npm ci failed on attempt $i"
# Check if it's a 403/registry error and clear cache
if [ $i -lt 3 ]; then
echo "🧹 Clearing npm cache to resolve potential registry issues..."
npm cache clean --force 2>/dev/null || true
echo "⏳ Waiting 30 seconds before retry..."
sleep 30
else
echo "⚠️ npm ci failed all attempts, trying advanced fallbacks..."
# Fallback 1: Clear cache and try npm install
echo "🔄 Fallback 1: Clearing cache and using npm install..."
npm cache clean --force 2>/dev/null || true
if npm install --legacy-peer-deps --no-audit --no-fund; then
echo "✅ npm install fallback succeeded"
break
fi
# Fallback 2: Use different registry
echo "🔄 Fallback 2: Trying with public registry explicitly..."
if NPM_CONFIG_REGISTRY=https://registry.npmjs.org/ npm install --legacy-peer-deps --no-audit --no-fund; then
echo "✅ Public registry fallback succeeded"
break
fi
# Fallback 3: Install without package-lock
echo "🔄 Fallback 3: Installing without package-lock.json..."
mv package-lock.json package-lock.json.backup 2>/dev/null || true
if npm install --legacy-peer-deps --no-audit --no-fund; then
echo "✅ No-lock installation succeeded"
mv package-lock.json.backup package-lock.json 2>/dev/null || true
break
fi
mv package-lock.json.backup package-lock.json 2>/dev/null || true
echo "💥 All npm installation methods failed"
exit 1
fi
fi
done
- name: Install composer dependencies
shell: bash
run: |
composer install --no-dev --no-scripts --optimize-autoloader --quiet
- name: Set package version
shell: bash
env:
PACKAGE_VERSION: ${{ inputs.PACKAGE_VERSION }}
run: |
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
echo "Building Hello Theme version: ${PACKAGE_VERSION}"
- name: Build Hello Theme
shell: bash
run: |
if [[ "${{ inputs.BUILD_SCRIPT_PATH }}" == npm* ]]; then
${{ inputs.BUILD_SCRIPT_PATH }}
else
bash "${{ inputs.BUILD_SCRIPT_PATH }}"
fi
- name: Create theme build directory
shell: bash
run: |
mkdir -p /tmp/hello-theme-builds
- name: Package Hello Theme
shell: bash
env:
PACKAGE_VERSION: ${{ inputs.PACKAGE_VERSION }}
run: |
# Create zip file with proper naming (following Hello Commerce pattern)
zip -r "/tmp/hello-theme-builds/hello-elementor-${PACKAGE_VERSION}.zip" . \
-x "node_modules/*" "test-results/*" "tests/*" ".git/*" "*.zip" \
"playwright-report/*" ".wp-env.json.*" ".wp-env"
- name: Move build to workspace
shell: bash
env:
PACKAGE_VERSION: ${{ inputs.PACKAGE_VERSION }}
run: |
mv "/tmp/hello-theme-builds/hello-elementor-${PACKAGE_VERSION}.zip" \
"./hello-elementor-${PACKAGE_VERSION}.zip"
echo "✅ Hello Theme build completed: hello-elementor-${PACKAGE_VERSION}.zip"
ls -la hello-elementor-*.zip