Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dop 5214 #51

Draft
wants to merge 118 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
797f521
DOP-5174 change how environment is determined
anabellabuckvar Nov 15, 2024
db3ebac
Merge branch 'main' into DOP-5174
anabellabuckvar Nov 19, 2024
e6b8799
DOP-5174 updating types, imports for populate-metadata
anabellabuckvar Nov 19, 2024
6cb6b0e
DOP-5174 return proper environment
anabellabuckvar Nov 19, 2024
edd9b88
DOP-5174 logging
anabellabuckvar Nov 19, 2024
b385bf9
DOP-5174 logging
anabellabuckvar Nov 19, 2024
9e89987
DOP-5174 remove logging
anabellabuckvar Nov 19, 2024
25cf534
DOP-5174 add comments
anabellabuckvar Nov 19, 2024
04a8a55
DOP-5174 fix commetns
anabellabuckvar Nov 19, 2024
7f07d86
DOP-5174 testing hardcoding docs-java as repoName
anabellabuckvar Nov 20, 2024
f01a8ce
DOP-5174 testing hardcoding docs-java as repoName
anabellabuckvar Nov 20, 2024
cf3da4c
DOP-5174 testing hardcoding docs-java as repoName
anabellabuckvar Nov 20, 2024
8fd4d38
DOP-5174 testing hardcoding docs-java as repoName
anabellabuckvar Nov 20, 2024
742899f
DOP-5174 removing hardcoded docs-java
anabellabuckvar Nov 20, 2024
9d713f4
DOP-5174 possibly get repo name from configenvironment
anabellabuckvar Nov 20, 2024
b60664b
DOP-5174 remove getting repoName from configenvironment
anabellabuckvar Nov 20, 2024
58d6a01
DOP-5174 logging
anabellabuckvar Nov 20, 2024
34a3ddd
DOP-5174 logging
anabellabuckvar Nov 20, 2024
9774891
DOP-5174 removing logs
anabellabuckvar Nov 20, 2024
7c0b49f
DOP-5174 update search database name to search-staging instead of sea…
anabellabuckvar Nov 20, 2024
13f3e55
DOP-5201 logging incoming hook body
anabellabuckvar Nov 21, 2024
8362691
feat/slack set repoName and branchName from build hook payload
anabellabuckvar Nov 21, 2024
31d1835
feat/slack set repoName and branchName from build hook payload
anabellabuckvar Nov 21, 2024
3eb77f1
DOP-5201 logging
anabellabuckvar Nov 21, 2024
174d096
DOP-5201 using incoming hook body
anabellabuckvar Nov 21, 2024
8dd6ac0
feat/slack testing hardcoded vars
anabellabuckvar Nov 21, 2024
6a04b1b
DOP-5201 add types, function for gettin project metadata from atlas
anabellabuckvar Nov 21, 2024
3438911
DOP-5201 get metadataEntry
anabellabuckvar Nov 21, 2024
d5656fe
DOP-5201 get metadataEntry
anabellabuckvar Nov 21, 2024
321b778
DOP-5201 logging
anabellabuckvar Nov 22, 2024
3101e82
DOP-5201 set org as env var
anabellabuckvar Nov 22, 2024
1085116
DOP-5201 hardcoding repoName, branchName
anabellabuckvar Nov 22, 2024
68fc1b3
DOP-5201 hardcoding docs-cpp
anabellabuckvar Nov 22, 2024
bfd91ee
DOP-5201 hardcoding docs-cpp
anabellabuckvar Nov 22, 2024
d597273
DOP-5201 possibly unhardcoding docs-cpp
anabellabuckvar Nov 22, 2024
e292c0c
DOP-5201 hardcode bi-connector
anabellabuckvar Nov 22, 2024
62172af
DOP-5201 update types
anabellabuckvar Nov 22, 2024
d69f1a3
DOP-5201 logging and add conditional
anabellabuckvar Nov 22, 2024
3bfbc8e
DOP-5201 un-hardcode
anabellabuckvar Nov 22, 2024
a49ab97
DOP-5201 set repo org
anabellabuckvar Nov 22, 2024
be620a8
DOP-5201 updating database connection files
anabellabuckvar Nov 26, 2024
e461aa2
DOP-5201 update imports
anabellabuckvar Nov 26, 2024
c9c85ea
DOP-5201 add more types
anabellabuckvar Nov 26, 2024
a5fdd89
DOP-5201 update typing and collection connection functions
anabellabuckvar Nov 27, 2024
da1e60b
DOP-5201 add comments of TODOs for redoc extension
anabellabuckvar Nov 27, 2024
eec8406
Merge branch 'main' into DOP-5201
anabellabuckvar Nov 27, 2024
c7d0cb4
DOP-5201 lint and format
anabellabuckvar Nov 27, 2024
43bf748
DOP-5215 some refactoring, testing run command
anabellabuckvar Dec 2, 2024
088b8fc
DOP-5215 clone content repo when on frontend site
anabellabuckvar Dec 2, 2024
7ab965d
DOP-5215 set metadata entry and use better logging
anabellabuckvar Dec 2, 2024
e554b63
DOP-5215 add if statement, log files in cwd
anabellabuckvar Dec 2, 2024
77cfd79
DOP-5215 remove directory
anabellabuckvar Dec 2, 2024
8f5d800
DOP-5215 remove directory
anabellabuckvar Dec 2, 2024
372a7ba
DOP-5215 remove directory
anabellabuckvar Dec 2, 2024
35bd0ee
DOP-5215 check if directory exists, logging, fixing typos
anabellabuckvar Dec 3, 2024
10256d7
DOP-5215 remove additional log
anabellabuckvar Dec 3, 2024
16f68a4
DOP-5215 use github bot pwd
anabellabuckvar Dec 3, 2024
56f4de6
DOP-5215 use github bot pwd
anabellabuckvar Dec 3, 2024
da55a2b
DOP-5215 undo using github bot pwd
anabellabuckvar Dec 3, 2024
b578280
DOP-5215 use github pwd w silent option
anabellabuckvar Dec 3, 2024
e5a8d8f
DOP-5215 add username when cloning
anabellabuckvar Dec 3, 2024
1b47b45
DOP-5215 change how pwd is used
anabellabuckvar Dec 3, 2024
998f0a1
DOP-5215 write pwd to askpass file
anabellabuckvar Dec 3, 2024
bd9287c
DOP-5215 remove exec from command
anabellabuckvar Dec 3, 2024
dd3fba1
DOP-5215 set askpass env var
anabellabuckvar Dec 3, 2024
da2b78c
DOP-5215 set askpass env var
anabellabuckvar Dec 3, 2024
f82f605
DOP-5215 logging
anabellabuckvar Dec 3, 2024
8accc39
DOP-5215 logging
anabellabuckvar Dec 3, 2024
7a2a089
DOP-5215 create new file
anabellabuckvar Dec 3, 2024
d1f8247
DOP-5215 create testing file
anabellabuckvar Dec 3, 2024
bba8b6a
DOP-5215 create testing file
anabellabuckvar Dec 3, 2024
26ea55d
DOP-5215 change path
anabellabuckvar Dec 3, 2024
6a32d4e
DOP-5215 change name of file
anabellabuckvar Dec 3, 2024
1d42ccf
DOP-5215 use octokit
anabellabuckvar Dec 3, 2024
5cc90c4
DOP-5215 add await to octokit request
anabellabuckvar Dec 3, 2024
abdcf9e
DOP-5215 get branch with octokit
anabellabuckvar Dec 3, 2024
929014d
DOP-5215 get branch with octokit
anabellabuckvar Dec 3, 2024
70807dd
DOP-5215 fix repoName typo
anabellabuckvar Dec 5, 2024
3e7f236
DOP-5215 log config env
anabellabuckvar Dec 5, 2024
79f3528
DOP-5215 use site url
anabellabuckvar Dec 5, 2024
895eb5b
DOP-5215 comment out some logs
anabellabuckvar Dec 6, 2024
5950705
DOP-5215 readfilesync
anabellabuckvar Dec 6, 2024
03bf8db
DOP-5215 use cat instead of readfilesync
anabellabuckvar Dec 6, 2024
63e53ae
DOP-5215 use cat instead of readfilesync
anabellabuckvar Dec 6, 2024
461038b
DOP-5215 create testing file
anabellabuckvar Dec 6, 2024
3b8f750
DOP-5215 commenting out
anabellabuckvar Dec 6, 2024
060acb1
DOP-5215 commenting out askpass
anabellabuckvar Dec 6, 2024
69dcc3b
DOP-5215 remove git config after cloning
anabellabuckvar Dec 6, 2024
d85ee1f
DOP-5215 list all files
anabellabuckvar Dec 6, 2024
764db87
DOP-5215 fix typo
anabellabuckvar Dec 6, 2024
e543498
DOP-5215 fix typo
anabellabuckvar Dec 6, 2024
26d7cbd
DOP-5215 clean up
anabellabuckvar Dec 9, 2024
d6e2aa7
DOP-5215 clean up more + some refactoring
anabellabuckvar Dec 9, 2024
d7d0f8d
DOP-5215 add await
anabellabuckvar Dec 9, 2024
e01c69a
Merge branch 'main' into DOP-5215
anabellabuckvar Dec 10, 2024
158c781
DOP-5215 capitalize types
anabellabuckvar Dec 10, 2024
0bcdae1
DOP-5215 fixing typing
anabellabuckvar Dec 10, 2024
b04c05b
DOP-5215 lint and format
anabellabuckvar Dec 10, 2024
7d2f622
DOP-5214 logging repos selected
anabellabuckvar Dec 10, 2024
12e6590
DOP-5214 logging repos selected
anabellabuckvar Dec 10, 2024
7d9ac51
DOP-5214 remove return statement
anabellabuckvar Dec 10, 2024
31c3218
DOP-5214 remove return statement
anabellabuckvar Dec 10, 2024
ec1940c
DOP-5214 add timeout function
anabellabuckvar Dec 12, 2024
b613bbe
DOP-5214 add timeout function
anabellabuckvar Dec 12, 2024
ece710c
DOP-5214 refactor asyncTimeout
anabellabuckvar Dec 12, 2024
1f0e4f7
DOP-5214 reduce ms in asyncTimeout
anabellabuckvar Dec 13, 2024
cc01672
DOP-5214 reduce ms in asyncTimeout
anabellabuckvar Dec 13, 2024
e2ded9b
DOP-5214 reduce ms in asyncTimeout
anabellabuckvar Dec 13, 2024
18599db
DOP-5214 reduce ms in asyncTimeout
anabellabuckvar Dec 13, 2024
3e8c0a8
DOP-5214 reduce ms in asyncTimeout
anabellabuckvar Dec 13, 2024
a9617a1
DOP-5214 recall deploy repos
anabellabuckvar Dec 13, 2024
f358508
DOP-5214
anabellabuckvar Dec 13, 2024
5120c91
DOP-5214 create a dummy file
anabellabuckvar Dec 13, 2024
f8a07b3
DOP-5214 create a dummy file
anabellabuckvar Dec 13, 2024
14144dc
DOP-5214 create a dummy file
anabellabuckvar Dec 13, 2024
a217b81
DOP-5214 create a dummy file
anabellabuckvar Dec 13, 2024
44a6cbe
DOP-5214 create a dummy file
anabellabuckvar Dec 13, 2024
8862e5c
DOP-5214 create a dummy file
anabellabuckvar Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions extensions/populate-metadata/src/getProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type {
PoolDBName,
DocsetsDocument,
ReposBranchesDocument,
clusterZeroConnectionInfo,
ProjectMetadataDocument,
ClusterZeroConnectionInfo,
ProjectsDocument,
ClusterZeroDBName,
} from 'util/databaseConnection/types';
const EXTENSION_NAME = 'populate-metadata-extension';
Expand All @@ -23,7 +23,7 @@ const getDocsetEntry = async ({
projectName,
environment,
}: {
docsetsConnectionInfo: clusterZeroConnectionInfo;
docsetsConnectionInfo: ClusterZeroConnectionInfo;
projectName: string;
environment: Environments;
}): Promise<DocsetsDocument> => {
Expand Down Expand Up @@ -56,7 +56,7 @@ const getRepoEntry = async ({
}: {
repoName: string;
branchName: string;
connectionInfo: clusterZeroConnectionInfo;
connectionInfo: ClusterZeroConnectionInfo;
}): Promise<ReposBranchesDocument> => {
const reposBranches = await getReposBranchesCollection(connectionInfo);

Expand Down Expand Up @@ -88,13 +88,13 @@ const getRepoEntry = async ({
return repo;
};

const getMetadataEntry = async ({
const getProjectsEntry = async ({
projectName,
connectionInfo,
}: {
projectName: string;
connectionInfo: clusterZeroConnectionInfo;
}): Promise<ProjectMetadataDocument> => {
connectionInfo: ClusterZeroConnectionInfo;
}): Promise<ProjectsDocument> => {
const projects = await getProjectsCollection(connectionInfo);
const query = {
name: projectName,
Expand All @@ -109,7 +109,7 @@ const getMetadataEntry = async ({
},
};

const projectMetadata = await projects.findOne<ProjectMetadataDocument>(
const projectMetadata = await projects.findOne<ProjectsDocument>(
query,
projection,
);
Expand Down Expand Up @@ -139,7 +139,7 @@ export const getProperties = async ({
}): Promise<{
repo: ReposBranchesDocument;
docsetEntry: DocsetsDocument;
metadataEntry: ProjectMetadataDocument;
projectsEntry: ProjectsDocument;
}> => {
const repoBranchesConnectionInfo = {
clusterZeroURI: dbEnvVars.ATLAS_CLUSTER0_URI,
Expand Down Expand Up @@ -174,12 +174,12 @@ export const getProperties = async ({
extensionName: EXTENSION_NAME,
};

const metadataEntry = await getMetadataEntry({
const projectsEntry = await getProjectsEntry({
connectionInfo: projectMetadataConnectionInfo,
projectName: repo.project,
});

await closeClusterZeroDb();

return { repo, docsetEntry, metadataEntry };
return { repo, docsetEntry, projectsEntry };
};
3 changes: 2 additions & 1 deletion extensions/populate-metadata/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ const extension = new Extension({

extension.addBuildEventHandler(
'onPreBuild',
async ({ netlifyConfig, dbEnvVars }) => {
async ({ netlifyConfig, dbEnvVars, utils: { run } }) => {
await updateConfig({
configEnvironment: netlifyConfig?.build?.environment,
dbEnvVars,
run,
});
},
);
Expand Down
129 changes: 87 additions & 42 deletions extensions/populate-metadata/src/updateConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@ import type {
PoolDBName,
SnootyDBName,
SearchDBName,
OrganizationName,
} from 'util/databaseConnection/types';
import { getProperties } from './getProperties';
import type { ConfigEnvironmentVariables } from 'util/extension';
import type { StaticEnvVars } from 'util/assertDbEnvVars';
import type { NetlifyPluginUtils } from '@netlify/build';
import * as fs from 'node:fs';

const FRONTEND_SITES = [
'docs-frontend-stg',
'docs-frontend-dotcomstg',
'docs-frontend-dotcomprd',
];

const getDbNames = (
env: Environments,
Expand Down Expand Up @@ -47,15 +56,9 @@ const determineEnvironment = ({
siteName,
}: { isBuildHookDeploy: boolean; siteName: string }): Environments => {
// Check if this was an engineer's build or writer's build
const frontendSites = [
'docs-frontend-stg',
'docs-frontend-dotcomstg',
'docs-frontend-dotcomprd',
];
const isFrontendBuild = frontendSites.includes(siteName);
const isFrontendBuild = FRONTEND_SITES.includes(siteName);

//Writer's builds = prd, everything not built on a frontend site (a site with 'Snooty' as git source)

if (!isFrontendBuild) {
return 'prd';
}
Expand All @@ -69,17 +72,75 @@ const determineEnvironment = ({
}
return 'stg';
};

const cloneContentRepo = async ({
run,
repoName,
branchName,
orgName,
}: {
run: NetlifyPluginUtils['run'];
repoName: string;
branchName: string;
orgName: string;
}) => {
if (fs.existsSync(`${process.cwd()}/${repoName}`)) {
await run.command(`rm -r ${repoName}`);
}

await run.command(
`git clone -b ${branchName} https://${process.env.GITHUB_BOT_USERNAME}:${process.env.GITHUB_BOT_PWD}@github.com/${orgName}/${repoName}.git -s`,
);

if (fs.existsSync(`${repoName}/.git/config`)) {
// Remove git config as it stores the connection string in plain text
await run.command(`rm -r ${repoName}/.git/config`);
}
await run.command(`touch ${repoName}/${branchName}`);
await run.command(
`echo "${repoName}, ${branchName}" > ${repoName}/${branchName}`,
);
await run.command('ls');
console.log(fs.readFileSync(`${repoName}/${branchName}`));
};

export const updateConfig = async ({
configEnvironment,
dbEnvVars,
run,
}: {
configEnvironment: ConfigEnvironmentVariables;
dbEnvVars: StaticEnvVars;
run: NetlifyPluginUtils['run'];
}): Promise<void> => {
// Check if this was a build triggered by a frontend change or a content repo change
const isFrontendBuild = FRONTEND_SITES.includes(
configEnvironment.SITE_NAME as string,
);
// Checks if build was triggered by a webhook
const isBuildHookDeploy = !!(
configEnvironment.INCOMING_HOOK_URL && configEnvironment.INCOMING_HOOK_TITLE
);

// Determine which repository and branch to build
// Check if repo name and branch name have been set as environment variables through Netlify UI, allows overwriting of database name values
const repoName = isBuildHookDeploy
? JSON.parse(configEnvironment?.INCOMING_HOOK_BODY as string)?.repoName
: (process.env.REPO_NAME ??
(process.env.REPOSITORY_URL?.split('/')?.pop() as string));

const branchName: string = isBuildHookDeploy
? JSON.parse(configEnvironment?.INCOMING_HOOK_BODY as string)?.branchName
: (process.env.BRANCH_NAME ?? (configEnvironment.BRANCH as string));

if (!repoName || !branchName) {
throw new Error('Repo name or branch name missing from deploy');
}

configEnvironment.BRANCH_NAME = branchName;
configEnvironment.REPO_NAME = repoName;

// Determine which environment the build will run in
const env = determineEnvironment({
isBuildHookDeploy,
siteName: configEnvironment.SITE_NAME as string,
Expand All @@ -89,6 +150,7 @@ export const updateConfig = async ({

configEnvironment.ENV = buildEnvironment;

// Get the names of the databases associated with given build environment
const { snootyDb, searchDb, poolDb } = getDbNames(buildEnvironment);

// Check if values for the database names have been set as environment variables through Netlify UI
Expand All @@ -102,51 +164,34 @@ export const updateConfig = async ({
configEnvironment.SNOOTY_DB_NAME =
(process.env.SNOOTY_DB_NAME as SnootyDBName) ?? snootyDb;

// Check if repo name and branch name have been set as environment variables through Netlify UI
// Allows overwriting of database name values for testing
let branchName: string;
let repoName: string;
if (buildEnvironment !== 'dotcomstg' && buildEnvironment !== 'dotcomprd') {
branchName =
process.env.BRANCH_NAME ?? (configEnvironment.BRANCH as string);
repoName =
process.env.REPO_NAME ??
(process.env.REPOSITORY_URL?.split('/')?.pop() as string);
} else {
console.log(`Incoming hook body ${configEnvironment?.INCOMING_HOOK_BODY}`);
repoName = JSON.parse(
configEnvironment?.INCOMING_HOOK_BODY as string,
)?.repoName;
branchName = JSON.parse(
configEnvironment?.INCOMING_HOOK_BODY as string,
)?.branchName;
}

if (!repoName) {
throw new Error('Repo name missing from deploy');
}
if (!branchName) {
throw new Error('Branch name missing from deploy');
}
configEnvironment.BRANCH_NAME = branchName;
configEnvironment.REPO_NAME = repoName;

const { repo, docsetEntry, metadataEntry } = await getProperties({
const { repo, docsetEntry, projectsEntry } = await getProperties({
branchName,
repoName,
dbEnvVars,
poolDbName: configEnvironment.POOL_DB_NAME,
environment: buildEnvironment,
});
configEnvironment.ORG = metadataEntry.github.organization;
// Set process.env SNOOTY_ENV and PREFIX_PATH environment variables for frontend to retrieve at build time
process.env.SNOOTY_ENV = buildEnvironment;
process.env.PATH_PREFIX = docsetEntry.prefix[buildEnvironment];

const { branches: branch, ...repoEntry } = repo;
configEnvironment.REPO_ENTRY = repoEntry;
configEnvironment.DOCSET_ENTRY = docsetEntry;
configEnvironment.BRANCH_ENTRY = branch?.pop();
configEnvironment.PROJECTS_ENTRY = projectsEntry;

const orgName = projectsEntry.github.organization;
configEnvironment.ORG = orgName as OrganizationName;

// Set process.env SNOOTY_ENV and PREFIX_PATH environment variables for frontend to retrieve at build time
process.env.SNOOTY_ENV = buildEnvironment;
process.env.PATH_PREFIX = docsetEntry.prefix[buildEnvironment];

// Prep for Snooty frontend build by cloning content repo
if (isFrontendBuild) {
console.log(
`Cloning content repo \n Repo: ${repoName}, branch: ${branchName}, github organization: ${orgName}`,
);
await cloneContentRepo({ run, repoName, branchName, orgName });
}

console.info(
'BUILD ENVIRONMENT: ',
Expand All @@ -158,7 +203,7 @@ export const updateConfig = async ({
'\n BRANCH ENTRY: ',
configEnvironment.BRANCH_ENTRY,
'\n METADATA ENTRY: ',
configEnvironment.METADATA_ENTRY,
configEnvironment.PROJECTS_ENTRY,
'\n POOL DB NAME: ',
configEnvironment.POOL_DB_NAME,
'\n SEARCH DB NAME: ',
Expand Down
103 changes: 103 additions & 0 deletions extensions/search-manifest/src/generateAndUpload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import type { NetlifyPluginUtils } from '@netlify/build';
import type { StaticEnvVars } from 'util/assertDbEnvVars';
import type { ConfigEnvironmentVariables } from 'util/extension';
import { getSearchProperties } from './uploadToAtlas/getProperties';
import type {
SearchDBName,
BranchEntry,
DocsetsDocument,
ReposBranchesDocument,
S3UploadParams,
} from 'util/databaseConnection/types';
import { generateManifest } from './generateManifest';
import { uploadManifest } from './uploadToAtlas/uploadManifest';
import { uploadManifestToS3 } from './uploadToS3/uploadManifest';

const EXTENSION_NAME = 'search-manifest';

export const generateAndUploadManifests = async ({
configEnvironment,
run,
dbEnvVars,
}: {
configEnvironment: ConfigEnvironmentVariables;
run: NetlifyPluginUtils['run'];
dbEnvVars: StaticEnvVars;
}) => {
// Get content repo zipfile as AST representation
await run.command('unzip -o bundle.zip');

const branchName = configEnvironment.BRANCH;
const repoName = configEnvironment.SITE_NAME;
if (!repoName || !branchName) {
// Check that an environment variable for repo name was set
throw new Error(
'Repo or branch name was not found, manifest cannot be uploaded to Atlas or S3 ',
);
}

const manifest = await generateManifest();

console.log('=========== Finished generating manifests ================');

// TODO: this should be made into its own type
const searchConnectionInfo = {
searchURI: dbEnvVars.ATLAS_SEARCH_URI,
databaseName: configEnvironment.SEARCH_DB_NAME as SearchDBName,
collectionName: dbEnvVars.DOCUMENTS_COLLECTION,
extensionName: EXTENSION_NAME,
};

const {
url,
searchProperty,
includeInGlobalSearch,
}: {
url: string;
searchProperty: string;
includeInGlobalSearch: boolean;
} = await getSearchProperties({
branchEntry: configEnvironment.BRANCH_ENTRY as BranchEntry,
docsetEntry: configEnvironment.DOCSET_ENTRY as DocsetsDocument,
repoEntry: configEnvironment.REPO_ENTRY as ReposBranchesDocument,
connectionInfo: searchConnectionInfo,
});

const projectName = configEnvironment.REPO_ENTRY?.project;

console.log('=========== Uploading Manifests to S3=================');
const uploadParams: S3UploadParams = {
//TODO: change based on environments
bucket:
configEnvironment.ENV === 'dotcomstg'
? 'docs-search-indexes-test/preprd'
: 'docs-search-indexes-test/prd',
prefix: 'search-indexes/',
fileName: `${projectName}-${branchName}.json`,
manifest: manifest.export(),
};

const s3Status = await uploadManifestToS3({
uploadParams,
AWS_S3_ACCESS_KEY_ID: dbEnvVars.AWS_S3_ACCESS_KEY_ID,
AWS_S3_SECRET_ACCESS_KEY: dbEnvVars.AWS_S3_SECRET_ACCESS_KEY,
});

console.log(`S3 upload status: ${JSON.stringify(s3Status)}`);
console.log('=========== Finished Uploading to S3 ================');

try {
manifest.setUrl(url);
manifest.setGlobalSearchValue(includeInGlobalSearch);
console.log('=========== Uploading Manifests to Atlas =================');
const status = await uploadManifest({
manifest,
searchProperty,
connectionInfo: searchConnectionInfo,
});
console.log(status);
console.log('=========== Manifests uploaded to Atlas =================');
} catch (e) {
console.log('Manifest could not be uploaded', e);
}
};
Loading