From cf5a7526b65d7f024955899264bc6ba48de206d4 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sat, 15 Aug 2020 12:48:07 +0200 Subject: [PATCH] :wrench: Send patch request --- index.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e383945..a5b18cf 100644 --- a/index.js +++ b/index.js @@ -24,7 +24,28 @@ try { let data = {files: {}}; data.files[badgeName] = {content: JSON.stringify(description)}; - console.log(JSON.stringify(data)); + const options = { + host: 'api.github.com', + path: '/gists/' + gistId, + auth: 'token ' + auth, + method: 'PATCH' + }; + + const callback = (response) => { + let str = ''; + + response.on('data', (chunk) => { + str += chunk; + }); + + response.on('end', () => { + console.log(str); + }); + }; + + const req = http.request(options, callback); + req.write(JSON.stringify(data)); + req.end(); } catch (error) { core.setFailed(error.message);