From eb5c99911b6809de82893561428fe007a3920204 Mon Sep 17 00:00:00 2001 From: Mehmet TOSUN Date: Fri, 5 Dec 2025 12:11:07 +0300 Subject: [PATCH] fix workflow --- .github/workflows/build-and-publish.yml | 42 +++++++++++++++++++++---- package.json | 2 +- setup.js | 30 +++++++++++++++--- 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 5081a3a..d055641 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -112,12 +112,42 @@ jobs: - name: Install dependencies run: | echo "Installing dependencies..." - if [ -f "package-lock.json" ]; then - npm ci - else - npm install - fi - echo "Dependencies installed successfully" + + # Retry function for npm install + install_with_retry() { + local max_attempts=3 + local attempt=1 + local delay=5 + + while [ $attempt -le $max_attempts ]; do + echo "Attempt $attempt of $max_attempts..." + + if [ -f "package-lock.json" ]; then + if npm ci; then + echo "✅ Dependencies installed successfully" + return 0 + fi + else + if npm install; then + echo "✅ Dependencies installed successfully" + return 0 + fi + fi + + if [ $attempt -lt $max_attempts ]; then + echo "⚠️ Installation failed, retrying in ${delay} seconds..." + sleep $delay + delay=$((delay * 2)) # Exponential backoff + fi + + attempt=$((attempt + 1)) + done + + echo "❌ Failed to install dependencies after $max_attempts attempts" + return 1 + } + + install_with_retry - name: Validate JSON schemas run: | diff --git a/package.json b/package.json index d6f4aa6..2a06e54 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build": "echo 'Build completed - package is ready'", "sync-schema": "node sync-schema-version.js", "setup": "node setup.js", - "postinstall": "node setup.js && npm run sync-schema", + "postinstall": "(node setup.js || true) && npm run sync-schema", "prepublishOnly": "npm run sync-schema && npm run validate" }, "bin": { diff --git a/setup.js b/setup.js index c0529f2..5ba1c6e 100755 --- a/setup.js +++ b/setup.js @@ -185,9 +185,13 @@ function isInstalledAsDependency() { return cwd.includes('node_modules'); } -// Check if running in non-interactive environment (like npm install) +// Check if running in non-interactive environment (like npm install or CI) function isNonInteractive() { - return !process.stdin.isTTY || process.env.CI === 'true' || process.env.NPM_CONFIG_INTERACTIVE === 'false'; + return !process.stdin.isTTY || + process.env.CI === 'true' || + process.env.GITHUB_ACTIONS === 'true' || + process.env.NPM_CONFIG_INTERACTIVE === 'false' || + process.env.CI === '1'; } // Get domain name from vnext.config.json @@ -232,18 +236,34 @@ async function setup() { return; } - console.log('🚀 vNext Template Setup'); - console.log('=======================\n'); - // Check if domain folder from vnext.config.json exists const domainFromConfig = getDomainFromConfig(); if (domainFromConfig && isDomainFolderConfigured()) { + // In CI/non-interactive mode, skip silently + if (isNonInteractive()) { + return; + } + // In interactive mode, show message + console.log('🚀 vNext Template Setup'); + console.log('=======================\n'); console.log(`✅ Domain "${domainFromConfig}" is already configured`); console.log(` Domain folder "${domainFromConfig}" exists and is set up.`); console.log(' Skipping setup. If you want to re-run setup, remove the domain directory first.\n'); return; } + // In CI/non-interactive mode, if touch doesn't exist or not configured, skip silently + if (isNonInteractive()) { + if (!fs.existsSync('touch')) { + return; + } + // If touch exists but we're in CI, skip silently (don't prompt) + return; + } + + console.log('🚀 vNext Template Setup'); + console.log('=======================\n'); + // Check if already set up if (isAlreadySetup()) { console.log('✅ Template is already set up with a domain name');