-
Notifications
You must be signed in to change notification settings - Fork 26
/
index.js
34 lines (28 loc) · 860 Bytes
/
index.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
const spsave = require("spsave").spsave;
const fs = require("fs");
const filePath = process.env.FILE_PATH
const fileExtensionArr = filePath.split('.')
const fileExtension = `.${fileExtensionArr[fileExtensionArr.length - 1]}`
const sha = process.env.GITHUB_SHA.substring(0, 7)
const trimSlashes = (string) => {
return string.replace(new RegExp('/', 'g'), '_')
}
let creds = {
clientId: process.env.CLIENTID,
clientSecret: process.env.CLIENTSECRET,
}
let coreOptions = {
siteUrl: process.env.SITE_URL,
}
let fileOptions = {
folder: process.env.LIB_FOLDER,
fileName: `${trimSlashes(process.env.GITHUB_REPOSITORY)}_${sha}_${fileExtension}`,
fileContent: fs.readFileSync(filePath),
}
spsave(coreOptions, creds, fileOptions)
.then(() => {
console.log('Success')
})
.catch((_) => {
process.exit(1)
})