🔧 Tweak code

This commit is contained in:
Simon Schneegans
2020-08-15 13:30:05 +02:00
parent a36c44cc09
commit d5c3a8eb60

View File

@@ -1,5 +1,5 @@
const core = require('@actions/core');
const http = require('http');
const http = require('https');
try {
let description = {
@@ -64,14 +64,16 @@ try {
data.files[core.getInput('badge-name')] = {
content: JSON.stringify(description)
};
data = JSON.stringify(data);
const req = http.request(
{
host: 'api.github.com',
path: '/gists/' + core.getInput('gist-id'),
method: 'PATCH',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length,
'Authorization': 'token ' + core.getInput('auth'),
}
},
@@ -84,13 +86,15 @@ try {
});
res.on('end', () => {
console.log(body);
console.log('result:' + body);
});
});
req.write(JSON.stringify(data));
req.write(data);
req.end();
console.log('all done');
} catch (error) {
core.setFailed(error);
}