-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
122,569 additions
and
288 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: generate-and-upload-card | ||
|
||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
generate: | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
|
||
steps: | ||
- name: generate github stats card | ||
uses: LuciNyan/pixel-profile/action@feat-github-action | ||
with: | ||
outputs: | | ||
dist/github-stats?username=LuciNyan&screen_effect=false&theme=fuji&dithering=true&hide=avatar | ||
dist/github-stats-dark?username=LuciNyan&theme=fuji&hide=avatar&avatar_border=false&screen_effect=true | ||
# push the content of <build_dir> to a branch | ||
# the content will be available at https://raw.githubusercontent.com/<github_user>/<repository>/<target_branch>/<file> , or as github page | ||
- name: push github-contribution-grid-snake.svg to the output branch | ||
uses: crazy-max/ghaction-github-pages@v3.1.0 | ||
with: | ||
target_branch: output | ||
build_dir: dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: "generate-pixel-github-stats" | ||
description: "Generates a github stats card from a github user contributions." | ||
author: "LuciNyan" | ||
|
||
runs: | ||
using: node20 | ||
main: libs/index.js | ||
|
||
inputs: | ||
github_token: | ||
description: "github token used to fetch the contribution data. Default to the action token if empty." | ||
required: false | ||
default: ${{ github.token }} | ||
outputs: | ||
required: false | ||
default: null | ||
description: | | ||
list of files to generate. |
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { parseOutputs } from './parseOutputs' | ||
import { parseArray, parseBoolean, parseString } from './utils' | ||
import * as core from '@actions/core' | ||
import * as fs from 'fs' | ||
import * as path from 'path' | ||
import { fetchStats, renderStats } from 'pixel-profile' | ||
|
||
async function main() { | ||
try { | ||
const githubToken = process.env.GITHUB_TOKEN ?? core.getInput('github_token') | ||
|
||
const options = parseOutputs(core.getMultilineInput('outputs')) | ||
|
||
for (const option of options) { | ||
if (option === null) continue | ||
|
||
const { | ||
background, | ||
color, | ||
exclude_repo, | ||
hide, | ||
include_all_commits, | ||
pixelate_avatar, | ||
screen_effect, | ||
show, | ||
username, | ||
theme, | ||
avatar_border, | ||
dithering, | ||
filename | ||
} = option | ||
|
||
const showStats = parseArray(show) | ||
const includeAllCommits = parseBoolean(include_all_commits) | ||
|
||
const stats: Parameters<typeof renderStats>[0] = await fetchStats( | ||
typeof username === 'string' ? username : '', | ||
includeAllCommits, | ||
parseArray(exclude_repo), | ||
showStats.includes('prs_merged') || showStats.includes('prs_merged_percentage'), | ||
showStats.includes('discussions_started'), | ||
showStats.includes('discussions_answered'), | ||
githubToken | ||
) | ||
|
||
const options = { | ||
background: parseString(background), | ||
color: parseString(color), | ||
hiddenStatsKeys: hide ? parseArray(hide) : undefined, | ||
includeAllCommits, | ||
pixelateAvatar: parseBoolean(pixelate_avatar), | ||
theme: parseString(theme), | ||
screenEffect: parseBoolean(screen_effect), | ||
avatarBorder: parseBoolean(avatar_border), | ||
dithering: parseBoolean(dithering), | ||
isFastMode: false | ||
} | ||
|
||
const result = await renderStats(stats, options) | ||
|
||
console.log(`💾 writing to ${filename}`) | ||
fs.mkdirSync(path.dirname(filename), { recursive: true }) | ||
fs.writeFileSync(filename, result) | ||
} | ||
} catch (e: any) { | ||
core.setFailed(`Action failed with "${e.message}"`) | ||
} | ||
} | ||
|
||
main() |
Oops, something went wrong.