ci: Fail release build on node popularity data fetch error (#20466)

This commit is contained in:
Eugene 2025-10-07 12:57:57 +02:00 committed by GitHub
parent 3e1a44bb29
commit 49064fc6da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

View File

@ -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: |

View File

@ -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();
}
}

View File

@ -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"],