-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.js
48 lines (35 loc) · 1.07 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* eslint-disable no-console */
'use strict'
const s3FolderUpload = require('s3-folder-upload')
if (!process.env.DEPLOY_ENV) {
throw new Error('DEPLOY_ENV is required')
}
const deployEnv = process.env.DEPLOY_ENV.replace(/"/g, '')
const targetFile = `BorosTcfStub.${deployEnv}.js`
const bucket = 'c.dcdn.es/borostcf/stub'
const invalidationPath = `/borostcf/stub/${targetFile}`
const region = 'eu-west-1'
const cloudfrontDistribution = 'E1IADXXISJ5K7B'
const directoryName = 'deploy'
const awsAccessKey = process.env.AWS_ACCESS_KEY
const awsSecret = process.env.AWS_SECRET_KEY
const credentials = {
accessKeyId: awsAccessKey,
secretAccessKey: awsSecret,
region: region,
bucket: bucket
}
const invalidation = {
awsDistributionId: cloudfrontDistribution,
awsInvalidationPath: invalidationPath
}
const options = {
useFoldersForFileTypes: false
}
const filesOptions = {
[targetFile]: {
CacheControl: 'public, max-age=3600'
}
}
console.log('>>> Credentials', JSON.stringify(credentials))
s3FolderUpload(directoryName, credentials, options, invalidation, filesOptions)