Skip to content

Commit 52b221b

Browse files
committed
Add the validate-config GitHub Action
This will come in handy once the project-specific settings start living in the `config` branch. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 94b18f2 commit 52b221b

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
@@ -56,7 +56,7 @@ export class CIHelper {
5656

5757
public static validateConfig = typia.createValidate<IConfig>();
5858

59-
protected static getConfigAsGitHubActionInput(): IConfig | undefined {
59+
public static getConfigAsGitHubActionInput(): IConfig | undefined {
6060
if (process.env.GITHUB_ACTIONS !== "true") return undefined;
6161
const json = core.getInput("config");
6262
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)