forked from Reggionick/s3-deploy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.js
30 lines (25 loc) · 986 Bytes
/
deploy.js
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
const path = require('path');
const exec = require('@actions/exec');
let deploy = function (params) {
return new Promise((resolve, reject) => {
const { folder, bucket, bucketRegion, distId, invalidation, deleteRemoved } = params;
const deleteRemovedArg = deleteRemoved ? `--deleteRemoved ${deleteRemoved}` : '';
try {
const command = `npx [email protected] ./** \
--bucket ${bucket} \
--region ${bucketRegion} \
--cwd . \
--distId ${distId} \
--etag \
--gzip xml,html,htm,js,css,ttf,otf,svg,txt \
--invalidate "${invalidation}" \
--noCache \
${deleteRemovedArg} `;
const cwd = path.resolve(folder);
exec.exec(command, [], { cwd }).then(resolve).catch(reject);
} catch (e) {
reject(e);
}
});
};
module.exports = deploy;