Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
26 changes: 25 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,34 @@ 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
default: "trophy.svg"
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:
Expand All @@ -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 }}" \
Comment thread
qoomon marked this conversation as resolved.
"${{ inputs.output_path }}" \
"${{ inputs.theme }}" \
"${{ inputs.title }}" \
"${{ inputs.column }}" \
"${{ inputs.no_frame }}" \
"${{ inputs.no_bg }}"
41 changes: 22 additions & 19 deletions render_svg.ts
Original file line number Diff line number Diff line change
@@ -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<string> = 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);
Expand All @@ -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,
);
Expand Down