diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 1e4efdcf377..306a8bf0f53 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -20,6 +20,8 @@ jobs: - name: Setup and Build ARM64 uses: ./.github/actions/setup-nodejs-blacksmith + env: + N8N_FAIL_ON_POPULARITY_FETCH_ERROR: true publish-to-npm: name: Publish to NPM @@ -40,6 +42,8 @@ jobs: - name: Setup and Build uses: ./.github/actions/setup-nodejs-github + env: + N8N_FAIL_ON_POPULARITY_FETCH_ERROR: true - name: Dry-run publishing run: | diff --git a/packages/frontend/editor-ui/scripts/fetch-node-popularity.mjs b/packages/frontend/editor-ui/scripts/fetch-node-popularity.mjs index 1e544623727..7c84a63257d 100755 --- a/packages/frontend/editor-ui/scripts/fetch-node-popularity.mjs +++ b/packages/frontend/editor-ui/scripts/fetch-node-popularity.mjs @@ -7,6 +7,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); const POPULARITY_ENDPOINT = process.env.NODE_POPULARITY_ENDPOINT || 'https://internal.users.n8n.cloud/webhook/nodes-popularity-scores'; +const FAIL_ON_ERROR = process.env.N8N_FAIL_ON_POPULARITY_FETCH_ERROR === 'true'; const BUILD_DIR = path.join(__dirname, '..', '.build'); const OUTPUT_FILE = path.join(BUILD_DIR, 'node-popularity.json'); @@ -76,13 +77,24 @@ async function main() { // Save the fresh data await savePopularityData(freshData); } else { - // Fetching failed, check if we have existing data + // Fetching failed + if (FAIL_ON_ERROR) { + console.error('N8N_FAIL_ON_POPULARITY_FETCH_ERROR is set - failing build'); + process.exit(1); + } + + // Check if we have existing data console.log('API unavailable, checking for existing cached data'); await fallbackToExistingData(); } } catch (error) { console.error('Error in fetch-node-popularity script:', error); + if (FAIL_ON_ERROR) { + console.error('N8N_FAIL_ON_POPULARITY_FETCH_ERROR is set - failing build'); + process.exit(1); + } + await fallbackToExistingData(); } } diff --git a/packages/frontend/editor-ui/turbo.json b/packages/frontend/editor-ui/turbo.json index 284e9bdced6..0f39073459a 100644 --- a/packages/frontend/editor-ui/turbo.json +++ b/packages/frontend/editor-ui/turbo.json @@ -9,7 +9,8 @@ "dependsOn": ["popularity-cache-marker"], "cache": true, "outputs": [".build/node-popularity.json"], - "inputs": ["scripts/fetch-node-popularity.mjs", ".build/cache-marker"] + "inputs": ["scripts/fetch-node-popularity.mjs", ".build/cache-marker"], + "env": ["N8N_FAIL_ON_POPULARITY_FETCH_ERROR"] }, "build": { "dependsOn": ["^build", "fetch-popularity"],