Skip to content
Merged
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
37 changes: 37 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Setup Node.js + PNPM and install Dependencies
description: |
This is a composite GitHub Action that:
- Sets up pnpm package manager
- Configures Node.js environment
- Installs project dependencies with caching

inputs:
node-version:
description: "Explicit node version. Otherwise fallback reading `.nvmrc`"

runs:
using: composite

steps:
- name: Install pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5

- name: Setup Node.js (via input)
if: ${{ inputs.node-version }}
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ inputs.node-version }}
cache: "pnpm"
registry-url: "https://registry.npmjs.org"

- name: Setup Node.js (via .nvmrc)
if: ${{ !inputs.node-version }}
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: ".nvmrc"
cache: "pnpm"
registry-url: "https://registry.npmjs.org"

- name: Install Dependencies
shell: bash
run: pnpm install --frozen-lockfile
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CI

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: "${{ github.workflow }}-${{ github.head_ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions: {}

jobs:
test:
name: Test ${{ matrix.node }} on ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
node: [22, 24]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}

permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
node-version: ${{ matrix.node }}

- name: Run E2E tests
run: pnpm run test
env:
PAT_1: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY_OWNER: "rickstaa"

code-checks:
name: Code checks

runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Dependencies
uses: ./.github/actions/install-dependencies

- name: Format
run: pnpm run format:check

- name: Lint (knip)
run: pnpm run lint:knip
26 changes: 0 additions & 26 deletions .github/workflows/e2e.yml

This file was deleted.

15 changes: 6 additions & 9 deletions .github/workflows/release.yml
Comment thread
martin-mfg marked this conversation as resolved.
Comment thread
martin-mfg marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
name: Release
name: Update version tags
on:
push:
branches-ignore:
- "**"
tags:
- "v*.*.*"
permissions:
contents: write

permissions: {}

jobs:
update-semver:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: haya14busa/action-update-semver@7d2c558640ea49e798d46539536190aff8c18715 # v1.5.1
with:
major_version_tag_only: true
- name: Create release
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2.6.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
node_modules

# OS
.DS_Store
.env
.vscode

# IDE
.idea/
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
*.code-workspace
7 changes: 2 additions & 5 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint-staged
npm test
pnpm lint-staged
pnpm test
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pnpm-lock.yaml
package-lock.json
yarn.lock
*.md
15 changes: 14 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"useTabs": false,
"semi": true,
"trailingComma": "all",
"singleQuote": false,
"trailingComma": "all"
"printWidth": 80,
"tabWidth": 2,
"overrides": [
{
"files": ["*.jsonc"],
"options": {
"trailingComma": "none"
}
}
]
}
22 changes: 13 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import core from "@actions/core";
import { mkdir, writeFile } from "node:fs/promises";
import path from "node:path";

import { getInput, info, setFailed, setOutput, warning } from "@actions/core";
import statsApi from "github-readme-stats/api/index.js";
import repoApi from "github-readme-stats/api/pin.js";
import topLangsApi from "github-readme-stats/api/top-langs.js";
Expand Down Expand Up @@ -32,14 +34,16 @@ const normalizeOptions = (options) => {
* @returns {Record<string, string>} Parsed options.
*/
const parseOptions = (value) => {
if (!value) return {};
if (!value) {
return {};
}

const trimmed = value.trim();
const options = {};
if (trimmed.startsWith("{")) {
try {
Object.assign(options, JSON.parse(trimmed));
} catch (error) {
} catch {
throw new Error("Invalid JSON in options.");
}
} else {
Expand Down Expand Up @@ -77,7 +81,7 @@ const cardHandlers = {
const validateCardOptions = (card, query, repoOwner) => {
if (!query.username && repoOwner) {
query.username = repoOwner;
core.warning("username not provided; defaulting to repository owner.");
warning("username not provided; defaulting to repository owner.");
}
switch (card) {
case "stats":
Expand All @@ -103,9 +107,9 @@ const validateCardOptions = (card, query, repoOwner) => {
};

const run = async () => {
const card = core.getInput("card", { required: true }).toLowerCase();
const optionsInput = core.getInput("options") || "";
const outputPathInput = core.getInput("path");
const card = getInput("card", { required: true }).toLowerCase();
const optionsInput = getInput("options") || "";
const outputPathInput = getInput("path");

const handler = cardHandlers[card];
if (!handler) {
Expand Down Expand Up @@ -136,10 +140,10 @@ const run = async () => {
}

await writeFile(outputPath, svg, "utf8");
core.info(`Wrote ${outputPath}`);
core.setOutput("path", outputPathValue);
info(`Wrote ${outputPath}`);
setOutput("path", outputPathValue);
};

run().catch((error) => {
core.setFailed(error instanceof Error ? error.message : String(error));
setFailed(error instanceof Error ? error.message : String(error));
});
5 changes: 0 additions & 5 deletions jest.config.js

This file was deleted.

Loading