-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
43 lines (37 loc) · 1.08 KB
/
index.ts
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
import * as fs from 'fs';
import * as url from 'node:url';
import * as core from '@actions/core';
import { App } from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';
import { StaticSite } from './cdk/static-site';
export const main = (): void => {
const app = core.getInput('app', { required: true });
const domain = core.getInput('domain', { required: true });
const stack = 'deploy';
core.info('Inputs are: ' + JSON.stringify({ app, stack, domain }));
const cdkApp = new App();
const cdkStack = new StaticSite(cdkApp, 'static-site', {
app,
stack,
stage: 'PROD',
domainName: domain,
});
const cfn = Template.fromStack(cdkStack).toJSON();
fs.writeFileSync('cfn.json', JSON.stringify(cfn, undefined, 2));
};
try {
// execute only if invoked as main script (rather than test)
if (import.meta.url.startsWith('file:')) {
// (A)
const modulePath = url.fileURLToPath(import.meta.url);
if (process.argv[1] === modulePath) {
// (B)
// Main ESM module
main();
}
}
} catch (e) {
const error = e as Error;
core.error(error);
core.setFailed(error.message);
}