[backend] fetch connector manifest from rolling or tag (#7328)

This commit is contained in:
Laurent Bonnet
2025-09-08 16:21:23 +02:00
committed by GitHub
parent 4a645830b6
commit 5e2505e443
2 changed files with 21 additions and 4 deletions

View File

@@ -49,6 +49,8 @@ jobs:
command: yarn install
- run:
working_directory: ~/opencti/opencti-platform/opencti-graphql
environment:
TAG_VERSION: $CIRCLE_TAG
command: yarn build
- slack/notify:
event: fail

View File

@@ -2,7 +2,14 @@ import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const SCHEMA_URL = 'https://raw.githubusercontent.com/OpenCTI-Platform/connectors/refs/heads/master/manifest.json';
const getSchemaURL = () => {
if (process.env.TAG_VERSION) {
return `https://raw.githubusercontent.com/OpenCTI-Platform/connectors/refs/tags/${process.env.TAG_VERSION}/manifest.json`;
}
// rolling
return 'https://raw.githubusercontent.com/OpenCTI-Platform/connectors/refs/heads/master/manifest.json';
};
// use tags instead of master if env from circle TAG is set
const OUTPUT_DIR = '../src/__generated__';
const OUTPUT_FILE = 'opencti-manifest.json';
@@ -11,14 +18,21 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
async function getConnectorManifest() {
console.info('📝 Getting connectors manifest');
const schemaUrl = getSchemaURL();
try {
console.info(`Fetching manifest from: ${SCHEMA_URL}`);
const res = await fetch(SCHEMA_URL);
// fetch file
console.info(`➡️ Fetching manifest from: ${schemaUrl}`);
const res = await fetch(schemaUrl);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.text();
// try to parse as json
console.info('➡️ Parsing manifest...');
JSON.parse(data);
// save file
console.info('➡️ Writing manifest file...');
const fullDir = path.resolve(__dirname, OUTPUT_DIR);
fs.mkdirSync(fullDir, { recursive: true });
const fullPath = path.join(fullDir, OUTPUT_FILE);
@@ -26,7 +40,8 @@ async function getConnectorManifest() {
console.info(`✅ Manifest saved to: ${fullPath}`);
} catch (err) {
console.error(`❌ Error: ${err.message}`);
console.error(`❌ Error: ${err.message}`, err);
console.error(err);
process.exit(1);
}
}