From b584f7612d8baef0cd097208c27a5efd31fa3540 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Wed, 11 Feb 2026 14:09:47 +0100 Subject: [PATCH] feat(inputs): add githubToken and helper methods to settings.ts - add parseList helper method which parses comma-separated strings into an array - add validateNumber helper method - add githubToken to the getSettings function - set githubToken as a secret to mask it from logs --- src/settings.ts | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/settings.ts b/src/settings.ts index 18fadba..d0888c5 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,3 +1,34 @@ -import type { Settings } from "./types"; +import { Input } from "./enums/input.ts"; +import type { Settings } from "./types/index.ts"; +import * as core from "@actions/core"; -export function getSettings(): Settings {} +function parseList(raw: string): string[] { + return raw + .split(",") + .map((s) => s.trim()) + .filter(Boolean); +} + +export function getSettings(): Settings { + const settings = { + // Repo Auth Token + githubToken: core.getInput(Input.GithubToken), + }; + + core.setSecret(settings.githubToken); + + validateSettings(settings); + + return settings; +} + +function validateNumber(value: number, name: string, min: number, max: number): void { + if (isNaN(value)) { + throw new Error(`"${name}" must be a valid number`); + } + if (value < min || value > max) { + throw new Error(`"${name}" must be between ${min} and ${max}, got ${value}`); + } +} + +function validateSettings(settings: Settings): void {}