You've already forked dynamic-badges-action
🔧 Tweak code
This commit is contained in:
12
index.js
12
index.js
@@ -1,5 +1,5 @@
|
|||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
const http = require('http');
|
const http = require('https');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let description = {
|
let description = {
|
||||||
@@ -64,14 +64,16 @@ try {
|
|||||||
data.files[core.getInput('badge-name')] = {
|
data.files[core.getInput('badge-name')] = {
|
||||||
content: JSON.stringify(description)
|
content: JSON.stringify(description)
|
||||||
};
|
};
|
||||||
|
data = JSON.stringify(data);
|
||||||
|
|
||||||
const req = http.request(
|
const req = http.request(
|
||||||
{
|
{
|
||||||
host: 'api.github.com',
|
host: 'api.github.com',
|
||||||
path: '/gists/' + core.getInput('gist-id'),
|
path: '/gists/' + core.getInput('gist-id'),
|
||||||
method: 'PATCH',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
'Content-Length': data.length,
|
||||||
'Authorization': 'token ' + core.getInput('auth'),
|
'Authorization': 'token ' + core.getInput('auth'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -84,13 +86,15 @@ try {
|
|||||||
});
|
});
|
||||||
|
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
console.log(body);
|
console.log('result:' + body);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
req.write(JSON.stringify(data));
|
req.write(data);
|
||||||
req.end();
|
req.end();
|
||||||
|
|
||||||
|
console.log('all done');
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error);
|
core.setFailed(error);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user