-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload_code.js
More file actions
35 lines (32 loc) · 876 Bytes
/
upload_code.js
File metadata and controls
35 lines (32 loc) · 876 Bytes
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
const axios = require('axios')
const fs = require('fs')
const instance = axios.create({
baseURL: 'https://api-aciddb.treasuredata.com/api',
headers: {'AUTHORIZATION': `TD1 ${process.env.TD_API_KEY}`, 'Content-Type': 'application/json'}
})
fs.readFile('dist/app.js', 'utf-8', function(err, data) {
if (err) {
return console.log(err);
}
const desc = [
process.env.GITHUB_SHA,
`repo: ${process.env.GITHUB_REPOSITORY}`,
`tag/branch: ${process.env.GITHUB_REF}`,
].join("\n")
var payload = {
"instanceId": "14", // Change this to the right instance ID
"namespace": "files",
"key": "app.js",
"secret": false,
"value": data,
"description": desc,
"valueEncoding": "string"
}
instance.post('/ctl/change_drafts', payload)
.then((res) => {
console.log(res)
})
.catch((err) => {
console.log(err)
})
})