You've already forked dynamic-badges-action
🔧 Add some initial code
This commit is contained in:
32
index.js
32
index.js
@@ -2,14 +2,30 @@ const core = require('@actions/core');
|
|||||||
const github = require('@actions/github');
|
const github = require('@actions/github');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// `who-to-greet` input defined in action metadata file
|
const auth = core.getInput('auth');
|
||||||
const nameToGreet = core.getInput('who-to-greet');
|
const gistId = core.getInput('gist-id');
|
||||||
console.log(`Hello ${nameToGreet}!`);
|
const badgeName = core.getInput('badge-name');
|
||||||
const time = (new Date()).toTimeString();
|
|
||||||
core.setOutput('time', time);
|
const label = core.getInput('label');
|
||||||
// Get the JSON webhook payload for the event that triggered the workflow
|
const message = core.getInput('message');
|
||||||
const payload = JSON.stringify(github.context.payload, undefined, 2)
|
const labelColor = core.getInput('label-color');
|
||||||
console.log(`The event payload: ${payload}`);
|
const color = core.getInput('color');
|
||||||
|
|
||||||
|
let description = {schemaVersion: 1, label: label, message: message};
|
||||||
|
|
||||||
|
if (labelColor != undefined) {
|
||||||
|
description.labelColor = labelColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (color != undefined) {
|
||||||
|
description.labelColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = {files: {}};
|
||||||
|
data.files[badgeName].content = JSON.stringify(description);
|
||||||
|
|
||||||
|
console.log(JSON.stringify(data));
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user