Skip to content

Commit 12cfeea

Browse files
committed
Merge branch 'validate-config'
Add a GitHub Action that can quickly and conveniently validate a project-config. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents f56731f + c0e591e commit 12cfeea

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

lib/ci-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class CIHelper {
6969

7070
public static validateConfig = typia.createValidate<IConfig>();
7171

72-
protected static getConfigAsGitHubActionInput(): IConfig | undefined {
72+
public static getConfigAsGitHubActionInput(): IConfig | undefined {
7373
if (process.env.GITHUB_ACTIONS !== "true") return undefined;
7474
const json = core.getInput("config");
7575
if (!json) return undefined;

validate-config/action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: 'Validate a GitGitGadget configuration'
2+
description: 'Parses and validates a JSON-formatted string containing a GitGitGadget configuration'
3+
author: 'Johannes Schindelin'
4+
inputs:
5+
config:
6+
description: 'The GitGitGadget configuration to use (see https://github.com/gitgitgadget/gitgitgadget/blob/HEAD/lib/project-config.ts)'
7+
default: '' # sadly, ${{ vars.CONFIG }} does not work, and documentation about what contexts are permissible here is sorely missing
8+
runs:
9+
using: 'node20'
10+
main: './index.js'
11+
branding:
12+
icon: 'git-commit'
13+
color: 'orange'

validate-config/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
async function run() {
2+
const { CIHelper } = await import("../dist/index.js")
3+
4+
try {
5+
const config = CIHelper.getConfigAsGitHubActionInput()
6+
console.log(
7+
`This is a valid GitGitGadget configuration:\n${JSON.stringify(config, null, 2)}`,
8+
)
9+
} catch (e) {
10+
console.error(e)
11+
process.exitCode = 1
12+
}
13+
}
14+
15+
run()

0 commit comments

Comments
 (0)