forked from elastic/elastic-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirebase_pre_deploy.ts
More file actions
92 lines (79 loc) · 2.94 KB
/
firebase_pre_deploy.ts
File metadata and controls
92 lines (79 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import fs from 'fs';
import path from 'path';
import {
firebaseDeploy,
downloadArtifacts,
getChartsPackageMetadata,
prepareChartsPackagesForDeployment,
startGroup,
decompress,
bkEnv,
} from '../../utils';
import { createDeploymentStatus, createOrUpdateDeploymentComment } from '../../utils/deployment';
void (async () => {
if (bkEnv.isPullRequest) {
await createOrUpdateDeploymentComment({
state: 'pending',
preDeploy: true,
});
} else {
await createDeploymentStatus({ state: 'in_progress' });
}
const outDir = 'e2e_server/public';
const docsSrc = '.buildkite/artifacts/docs/firebase.gz';
await downloadArtifacts(docsSrc, 'build_docs');
await decompress({
src: docsSrc,
dest: outDir,
});
const storybookSrc = '.buildkite/artifacts/storybook.gz';
await downloadArtifacts(storybookSrc, 'build_storybook');
await decompress({
src: storybookSrc,
dest: path.join(outDir, 'storybook'),
});
const e2eSrc = '.buildkite/artifacts/e2e_server.gz';
await downloadArtifacts(e2eSrc, 'build_e2e');
await decompress({
src: e2eSrc,
dest: path.join(outDir, 'e2e'),
});
const chartsPackage = bkEnv.isPullRequest ? await getChartsPackageMetadata(true) : null;
const chartsPackagePaths =
chartsPackage !== null ? await prepareChartsPackagesForDeployment(outDir, chartsPackage) : null;
startGroup('Check deployment files');
const hasDocsIndex = fs.existsSync('./e2e_server/public/index.html');
const hasStorybookIndex = fs.existsSync('./e2e_server/public/storybook/index.html');
const hasE2EIndex = fs.existsSync('./e2e_server/public/e2e/index.html');
const missingFiles = [
['docs', hasDocsIndex],
['storybook', hasStorybookIndex],
['e2e server', hasE2EIndex],
...(chartsPackagePaths
? ([
['live charts package tarball', fs.existsSync(chartsPackagePaths.liveTarballDest)],
['commit charts package tarball', fs.existsSync(chartsPackagePaths.commitTarballDest)],
['charts package manifest', fs.existsSync(chartsPackagePaths.manifestDest)],
['charts package index', fs.existsSync(chartsPackagePaths.indexDest)],
] as const)
: []),
]
.filter(([, exists]) => !exists)
.map<string>(([f]) => f as string);
if (missingFiles.length > 0) {
throw new Error(`Error: Missing deployment files: [${missingFiles.join(', ')}]`);
}
// Move 404 file to /e2e-report
fs.mkdirSync('./e2e_server/public/e2e-report');
fs.renameSync('./.buildkite/assets/404-report.html', './e2e_server/public/e2e-report/index.html');
await firebaseDeploy({
preDeploy: true,
});
})();