diff --git a/README.md b/README.md index 4a0ccfd0..ece2eabf 100644 --- a/README.md +++ b/README.md @@ -594,7 +594,7 @@ given your username, (Enviroment Vars: See [env-example](env-example)). Usage: ```bash -deno run --allow-net --allow-env --allow-read --allow-write ./render_svg.ts USERNAME OUTPUT_DIR THEME +deno run --allow-net --allow-env --allow-read --allow-write ./render_svg.ts USERNAME [OUTPUT_PATH] [THEME] [TITLE] [COLUMN] [NO_FRAME] [NO_BG] ``` ## Generate an svg inside Github CI (Workflow) @@ -607,11 +607,17 @@ Usage: ```yaml - name: Generate trophy - uses: Erik-Donath/github-profile-trophy@feature/generate-svg + uses: ryo-ma/github-profile-trophy@v1.0 with: username: your-username output_path: trophy.svg token: ${{ secrets.GITHUB_TOKEN }} + # Optional inputs: + theme: default # Theme name (default: "default") + title: Stars,Commits # Comma-separated trophy titles to include (default: all) + column: 8 # Max columns (default: 8) + no_frame: false # Disable trophy frame borders (default: false) + no_bg: false # Disable card background (default: false) ``` ## Self-hosting on Vercel diff --git a/action.yml b/action.yml index 7b7c8642..f5ba35e9 100644 --- a/action.yml +++ b/action.yml @@ -4,6 +4,7 @@ inputs: username: description: "GitHub username to generate the trophy for" required: true + default: ${{ github.repository_owner }} output_path: description: "Output path to write the SVG" required: true @@ -11,10 +12,26 @@ inputs: token: description: "PAT or token to use for GitHub API" required: true + default: ${{ github.token }} theme: description: "Theme for the card" required: false default: "default" + title: + description: "Comma-separated list of trophy titles to display (e.g. 'Stars,Commits')" + required: false + default: "" + column: + description: "Maximum number of columns" + required: false + no_frame: + description: "Disable trophy frame borders" + required: false + default: "false" + no_bg: + description: "Disable card background" + required: false + default: "false" runs: using: "composite" steps: @@ -28,4 +45,11 @@ runs: env: GITHUB_TOKEN1: ${{ inputs.token }} run: | - deno run --allow-net --allow-env --allow-read --allow-write $GITHUB_ACTION_PATH/render_svg.ts "${{ inputs.username }}" "${{ inputs.output_path }}" "${{ inputs.theme }}" + deno run --allow-net --allow-env --allow-read --allow-write $GITHUB_ACTION_PATH/render_svg.ts \ + "${{ inputs.username }}" \ + "${{ inputs.output_path }}" \ + "${{ inputs.theme }}" \ + "${{ inputs.title }}" \ + "${{ inputs.column }}" \ + "${{ inputs.no_frame }}" \ + "${{ inputs.no_bg }}" diff --git a/render_svg.ts b/render_svg.ts index f870eee8..2f13ae94 100644 --- a/render_svg.ts +++ b/render_svg.ts @@ -1,26 +1,37 @@ import "https://deno.land/x/dotenv@v0.5.0/load.ts"; +import { COLORS } from "./src/theme.ts"; +import { Card } from "./src/card.ts"; +import { CONSTANTS } from "./src/utils.ts"; +import { GithubApiService } from "./src/Services/GithubApiService.ts"; const username = Deno.args[0]; const outputPath = Deno.args[1] ?? "./assets/trophy.svg"; const themeName = Deno.args[2] ?? "default"; +const titleArg = Deno.args[3] ?? ""; +const columnArg = Deno.args[4]; +const noFrameArg = Deno.args[5] ?? String(CONSTANTS.DEFAULT_NO_FRAME); +const noBgArg = Deno.args[6] ?? String(CONSTANTS.DEFAULT_NO_BACKGROUND); if (!username) { console.error( - "Usage: deno run --allow-net --allow-env --allow-read --allow-write ./render_svg.ts USERNAME [OUTPUT_PATH] [THEME]", + "Usage: deno run --allow-net --allow-env --allow-read --allow-write ./render_svg.ts USERNAME [OUTPUT_PATH] [THEME] [TITLE] [COLUMN] [NO_FRAME] [NO_BG]", ); Deno.exit(1); } -import { GithubApiService } from "./src/Services/GithubApiService.ts"; -import { Card } from "./src/card.ts"; -import { COLORS } from "./src/theme.ts"; - async function main() { console.log("Starting trophy render..."); console.log("Username:", username); console.log("Output path:", outputPath); console.log("Theme:", themeName); + const titles: Array = titleArg + ? titleArg.split(",").map((t) => t.trim()).filter((t) => t.length > 0) + : []; + const maxColumn = columnArg ? parseInt(columnArg, 10) : titles.length; + const noFrame = noFrameArg === "true"; + const noBackground = noBgArg === "true"; + const svc = new GithubApiService(); const userInfoOrError = await svc.requestUserInfo(username); @@ -36,22 +47,14 @@ async function main() { const userInfo = userInfoOrError as any; - const panelSize = 115; - const maxRow = 10; - const maxColumn = -1; // auto - const marginWidth = 10; - const marginHeight = 10; - const noBackground = false; - const noFrame = false; - const card = new Card( + titles, [], - [], - maxColumn, - maxRow, - panelSize, - marginWidth, - marginHeight, + isNaN(maxColumn) ? CONSTANTS.DEFAULT_MAX_COLUMN : maxColumn, + CONSTANTS.DEFAULT_MAX_ROW, + CONSTANTS.DEFAULT_PANEL_SIZE, + CONSTANTS.DEFAULT_MARGIN_W, + CONSTANTS.DEFAULT_MARGIN_H, noBackground, noFrame, );