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
This commit is contained in:
peaklabs-dev committed 2026-02-12 22:04:53 +01:00
1 parent ef8879b998
commit b584f7612d
1 file changed
+33 -2
+33 -2
View File
@@ -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 {}