mirror of
https://github.com/darksaid98/auto-changelog.git
synced 2026-12-03 06:28:52 +00:00
feat: Add default token input value
This commit is contained in:
8 files changed
+71
-55
No files matched your search
+3
-49
@@ -1,12 +1,7 @@
|
||||
import type { GitHub } from "@actions/github/lib/utils";
|
||||
import { COMMIT_REGEX, InputI, LogsI, PR_REGEX, TYPES } from "./constants";
|
||||
|
||||
export async function generate(input: InputI): Promise<string> {
|
||||
const { octokit, owner, repo, sha, tagRef } = input;
|
||||
let { exclude } = input;
|
||||
|
||||
exclude = exclude.map(
|
||||
(type) => (TYPES as { [type: string]: string | undefined })[type] ?? type,
|
||||
);
|
||||
const { octokit, exclude, owner, repo, sha, tagRef } = input;
|
||||
|
||||
const repoUrl = `https://github.com/${owner}/${repo}`;
|
||||
const commits: LogsI = {};
|
||||
@@ -33,8 +28,7 @@ export async function generate(input: InputI): Promise<string> {
|
||||
if (flag === "ignore") continue;
|
||||
|
||||
type = trim(type);
|
||||
type =
|
||||
(TYPES as { [type: string]: string | undefined })[type] ?? TYPES.other;
|
||||
type = TYPES[type] ?? TYPES.other;
|
||||
|
||||
category = category ? trim(category) : "";
|
||||
|
||||
@@ -97,43 +91,3 @@ function trim(value: string): string {
|
||||
|
||||
return value.trim().replace(/ {2,}/g, " ");
|
||||
}
|
||||
|
||||
const COMMIT_REGEX = /^([^)]*)(?:\(([^)]*?)\)|):(.*?)(?:\[([^\]]+?)\]|)\s*$/;
|
||||
const PR_REGEX = /#([1-9]\d*)/g;
|
||||
|
||||
const TYPES = {
|
||||
breaking: "Breaking Changes",
|
||||
build: "Build System",
|
||||
ci: "Continuous Integration",
|
||||
chore: "Chores",
|
||||
deps: "Dependencies",
|
||||
docs: "Documentation Changes",
|
||||
feat: "New Features",
|
||||
fix: "Bug Fixes",
|
||||
other: "Other Changes",
|
||||
perf: "Performance Improvements",
|
||||
refactor: "Refactors",
|
||||
revert: "Reverts",
|
||||
style: "Code Style Changes",
|
||||
test: "Tests",
|
||||
};
|
||||
|
||||
interface LogsI {
|
||||
[type: string]: {
|
||||
[category: string]: LogI[];
|
||||
};
|
||||
}
|
||||
|
||||
interface LogI {
|
||||
title: string;
|
||||
commits: string[];
|
||||
}
|
||||
|
||||
export interface InputI {
|
||||
octokit: InstanceType<typeof GitHub>;
|
||||
exclude: string[];
|
||||
owner: string;
|
||||
repo: string;
|
||||
sha: string;
|
||||
tagRef?: string;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import type { GitHub } from "@actions/github/lib/utils";
|
||||
|
||||
export const COMMIT_REGEX =
|
||||
/^([^)]*)(?:\(([^)]*?)\)|):(.*?)(?:\[([^\]]+?)\]|)\s*$/;
|
||||
export const PR_REGEX = /#([1-9]\d*)/g;
|
||||
|
||||
export const TYPES: TypesI = {
|
||||
breaking: "Breaking Changes",
|
||||
build: "Build System",
|
||||
ci: "Continuous Integration",
|
||||
chore: "Chores",
|
||||
deps: "Dependencies",
|
||||
docs: "Documentation Changes",
|
||||
feat: "New Features",
|
||||
fix: "Bug Fixes",
|
||||
other: "Other Changes",
|
||||
perf: "Performance Improvements",
|
||||
refactor: "Refactors",
|
||||
revert: "Reverts",
|
||||
style: "Code Style Changes",
|
||||
test: "Tests",
|
||||
};
|
||||
|
||||
export interface TypesI {
|
||||
[type: string]: string;
|
||||
}
|
||||
|
||||
export interface LogsI {
|
||||
[type: string]: {
|
||||
[category: string]: LogI[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface LogI {
|
||||
title: string;
|
||||
commits: string[];
|
||||
}
|
||||
|
||||
export interface InputI {
|
||||
octokit: InstanceType<typeof GitHub>;
|
||||
exclude: string[];
|
||||
owner: string;
|
||||
repo: string;
|
||||
sha: string;
|
||||
tagRef?: string;
|
||||
}
|
||||
+6
-1
@@ -1,11 +1,16 @@
|
||||
import { getInput, info, setFailed, setOutput } from "@actions/core";
|
||||
import { context, getOctokit } from "@actions/github";
|
||||
import { generate } from "./changelog";
|
||||
import { TYPES } from "./constants";
|
||||
|
||||
async function run() {
|
||||
const token = getInput("token", { required: true });
|
||||
const exclude = getInput("exclude", { required: false }).split(",");
|
||||
const exclude = getInput("exclude", { required: false })
|
||||
.split(",")
|
||||
.map((type) => TYPES[type] ?? type);
|
||||
|
||||
const octokit = getOctokit(token);
|
||||
|
||||
const {
|
||||
repo: { owner, repo },
|
||||
sha,
|
||||
|
||||
Reference in new issue
Block a user