update action
This commit is contained in:
parent
53c107f15d
commit
327be5ad89
2 changed files with 29 additions and 17 deletions
24
action.ts
24
action.ts
|
@ -14,11 +14,14 @@ import {
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
const username = "domai-tb"; //core.getInput("username");
|
const username = core.getInput("username");
|
||||||
|
|
||||||
|
// Fetch Code::Stats API
|
||||||
const profile = await fetchProfile(username);
|
const profile = await fetchProfile(username);
|
||||||
const toplang = await fetchTopLanguages(username);
|
const toplang = await fetchTopLanguages(username);
|
||||||
const history = await fetchHistory(username, 32);
|
const history = await fetchHistory(username, 32);
|
||||||
|
|
||||||
|
// Generate Profile Summary Card
|
||||||
const profilecard = ReactDOMServer.renderToStaticMarkup(
|
const profilecard = ReactDOMServer.renderToStaticMarkup(
|
||||||
new ProfileCard(profile.username, profile.xp, profile.recentXp, {
|
new ProfileCard(profile.username, profile.xp, profile.recentXp, {
|
||||||
hide: parseArray(core.getInput("hide")),
|
hide: parseArray(core.getInput("hide")),
|
||||||
|
@ -35,11 +38,18 @@ async function main() {
|
||||||
}).render()
|
}).render()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log(`Generated ./codestats_profilecard_${username}.svg`);
|
||||||
|
fs.writeFileSync(`./codestats_profilecard_${username}.svg`, profilecard);
|
||||||
|
|
||||||
|
// Generate Top Languages Card
|
||||||
const toplangcard = ReactDOMServer.renderToStaticMarkup(
|
const toplangcard = ReactDOMServer.renderToStaticMarkup(
|
||||||
new TopLanguagesCard(username, toplang.langs, {
|
new TopLanguagesCard(username, toplang.langs, {
|
||||||
hide: parseArray(core.getInput("hide")),
|
hide: parseArray(core.getInput("hide")),
|
||||||
language_count: 21, // parseNumber(core.getInput("language_count")),
|
language_count: 21, // parseNumber(core.getInput("language_count")),
|
||||||
card_width: clampValue(parseNumber(core.getInput("card_width")) || 300, 500),
|
card_width: clampValue(
|
||||||
|
parseNumber(core.getInput("card_width")) || 300,
|
||||||
|
500
|
||||||
|
),
|
||||||
layout: "compact", // core.getInput("layout")
|
layout: "compact", // core.getInput("layout")
|
||||||
title: `Code::Stats of ${username}`, // core.getInput("title"),
|
title: `Code::Stats of ${username}`, // core.getInput("title"),
|
||||||
title_color: core.getInput("title_color"),
|
title_color: core.getInput("title_color"),
|
||||||
|
@ -50,6 +60,10 @@ async function main() {
|
||||||
}).render()
|
}).render()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log(`Generated ./codestats_toplangs_${username}.svg`);
|
||||||
|
fs.writeFileSync(`./codestats_toplangs_${username}.svg`, toplangcard);
|
||||||
|
|
||||||
|
// Generate History Card
|
||||||
const historycard = ReactDOMServer.renderToStaticMarkup(
|
const historycard = ReactDOMServer.renderToStaticMarkup(
|
||||||
new HistoryCard(username, history, {
|
new HistoryCard(username, history, {
|
||||||
hide: parseArray(core.getInput("hide")),
|
hide: parseArray(core.getInput("hide")),
|
||||||
|
@ -67,13 +81,11 @@ async function main() {
|
||||||
}).render()
|
}).render()
|
||||||
);
|
);
|
||||||
|
|
||||||
fs.writeFileSync(`./codestats_profilecard_${username}.svg`, profilecard);
|
console.log(`Generated ./codestats_history_${username}.svg`);
|
||||||
fs.writeFileSync(`./codestats_toplangs_${username}.svg`, toplangcard);
|
|
||||||
fs.writeFileSync(`./codestats_history_${username}.svg`, historycard);
|
fs.writeFileSync(`./codestats_history_${username}.svg`, historycard);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
//core.setFailed(error.message);
|
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
//core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
action.yml
22
action.yml
|
@ -1,13 +1,13 @@
|
||||||
name: 'Hello World'
|
name: Code::Stats Profile Cards
|
||||||
description: 'Greet someone and record the time'
|
author: domai-tb
|
||||||
inputs:
|
description: An infographics generator to display stats about your Code::Stats account!
|
||||||
who-to-greet: # id of input
|
|
||||||
description: 'Who to greet'
|
|
||||||
required: true
|
|
||||||
default: 'World'
|
|
||||||
outputs:
|
|
||||||
time: # id of output
|
|
||||||
description: 'The time we greeted you'
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node18'
|
using: 'node20'
|
||||||
main: 'action.ts'
|
main: 'action.ts'
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
username:
|
||||||
|
description: Code::Sats account username
|
||||||
|
required: true
|
||||||
|
default: domai-tb
|
||||||
|
|
Loading…
Add table
Reference in a new issue