From d5c3a8eb60ddcd540546d3316a158c3ca7f4a508 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sat, 15 Aug 2020 13:30:05 +0200 Subject: [PATCH] :wrench: Tweak code --- index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index d38c6cb..e435b9b 100644 --- a/index.js +++ b/index.js @@ -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); } \ No newline at end of file