-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move JS logic to the external NPM package https://www.npmjs.com/packa…
…ge/github-badge-action , with tests, prettier, eslint, etc
- Loading branch information
Showing
5 changed files
with
19 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,3 @@ | ||
const core = require('@actions/core'); | ||
const gradientBadge = require('gradient-badge'); | ||
const fs = require('fs'); | ||
const createBadgeFromInputs = require('github-badge-action'); | ||
|
||
|
||
try { | ||
|
||
// Get action inputs | ||
const label = core.getInput('label' ); | ||
const labelColor = core.getInput('label-color'); | ||
const status = `${core.getInput('status' )}`; // Ensure string | ||
const gradient = core.getInput('color' ) | ||
.split(',') // Color gradient as Array | ||
.map( color => color.trim(' ') ) // Clean spaces; | ||
const style = core.getInput('style' ); | ||
const icon = core.getInput('icon' ); | ||
const iconWidth = core.getInput('icon-width '); | ||
const scale = core.getInput('scale' ); | ||
const path = core.getInput('path' ); | ||
|
||
const inputs = { | ||
label, | ||
labelColor, | ||
status, | ||
gradient, | ||
style, | ||
icon: (icon && icon.length ? icon : null), | ||
iconWidth, | ||
scale, | ||
}; | ||
|
||
console.log("Generate badge using the given inputs and defaults: ", inputs); | ||
|
||
// Generate the badge | ||
const svgString = gradientBadge( inputs ); | ||
|
||
// Output badge contents to Action output | ||
core.setOutput("badge", svgString); | ||
|
||
// If path is defined, save SVG data to that file | ||
if ( path && path.length ) { | ||
console.log(`Write data to file ${path}...`); | ||
|
||
// In case an error occurred writing file, | ||
// exception is thrown and success messsage is not printed | ||
fs.writeFileSync(path, svgString); | ||
console.log("Data saved succesfully."); | ||
} | ||
|
||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
createBadgeFromInputs(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters