mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-22 00:11:02 -05:00
I hate the way GitHub Actions process inputs
This commit is contained in:
parent
8c7eeb8fd9
commit
af38f88370
3 changed files with 31 additions and 0 deletions
19
action.yml
19
action.yml
|
@ -8,66 +8,85 @@ inputs:
|
|||
modrinth-id:
|
||||
description: The ID of the Modrinth project to upload to
|
||||
required: false
|
||||
default: ${undefined}
|
||||
modrinth-token:
|
||||
description: A valid token for the Modrinth API
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
curseforge-id:
|
||||
description: The ID of the CurseForge project to upload to
|
||||
required: false
|
||||
default: ${undefined}
|
||||
curseforge-token:
|
||||
description: A valid token for the CurseForge API
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
github-tag:
|
||||
description: The tag name of the release to upload assets to
|
||||
required: false
|
||||
default: ${undefined}
|
||||
github-token:
|
||||
description: A valid token for the GitHub API
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
files:
|
||||
description: A glob of the files to upload
|
||||
required: false
|
||||
default: ${undefined}
|
||||
files-primary:
|
||||
description: A glob of the primary files to upload
|
||||
required: false
|
||||
default: ${undefined}
|
||||
files-secondary:
|
||||
description: A glob of the secondary files to upload
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
name:
|
||||
description: The name of the version
|
||||
required: false
|
||||
default: ${undefined}
|
||||
version:
|
||||
description: The version number
|
||||
required: false
|
||||
default: ${undefined}
|
||||
version-type:
|
||||
description: The type of the release - alpha, beta, or release
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
changelog:
|
||||
description: The changelog for this version
|
||||
required: false
|
||||
default: ${undefined}
|
||||
changelog-file:
|
||||
description: A glob of the changelog file
|
||||
required: false
|
||||
default: ${undefined}
|
||||
|
||||
loaders:
|
||||
description: A list of supported mod loaders
|
||||
required: false
|
||||
default: ${undefined}
|
||||
game-versions:
|
||||
description: A list of supported Minecraft versions
|
||||
required: false
|
||||
default: ${undefined}
|
||||
dependencies:
|
||||
description: A list of dependencies
|
||||
required: false
|
||||
default: ${undefined}
|
||||
version-resolver:
|
||||
description: Determines the way automatic game-versions resolvement works
|
||||
required: false
|
||||
default: ${undefined}
|
||||
java:
|
||||
description: A list of supported Java versions
|
||||
required: false
|
||||
default: ${undefined}
|
||||
runs:
|
||||
using: node12
|
||||
main: dist/index.js
|
|
@ -3,6 +3,8 @@ import process from "process";
|
|||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
interface InputObject extends Record<string, string | InputObject> { }
|
||||
|
||||
const undefinedValue = "${undefined}";
|
||||
|
||||
export function getInputAsObject(): Record<string, InputObject> {
|
||||
const inputs = Object.entries(process.env).filter(([key, _]) => key.startsWith("INPUT_"));
|
||||
const input = {};
|
||||
|
@ -14,6 +16,10 @@ export function getInputAsObject(): Record<string, InputObject> {
|
|||
}
|
||||
|
||||
function init(root: InputObject, path: string[], value: string): void {
|
||||
if (value === undefinedValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
const name = path.reduce((a, b, i) => a + (i === 0 ? b : (b.substring(0, 1).toUpperCase() + b.substring(1))), "");
|
||||
root[name] = value;
|
||||
if (path.length === 1) {
|
||||
|
|
|
@ -8,6 +8,7 @@ describe("getInputAsObject", () => {
|
|||
"object": { foo: "bar" },
|
||||
"number": 1,
|
||||
"array": ["foo", "bar"],
|
||||
"undefined": "${undefined}",
|
||||
|
||||
"files-primary": "primaryPath",
|
||||
"files-secondary": "secondaryPath",
|
||||
|
@ -64,4 +65,9 @@ describe("getInputAsObject", () => {
|
|||
expect(input).toHaveProperty("this.is.a.very.long.name", "foo");
|
||||
expect(input).toHaveProperty("thisIsAVeryLongName", "foo");
|
||||
});
|
||||
|
||||
test("special case for GitHub Actions: ${undefined} transforms into undefined", () => {
|
||||
const input = getInputAsObject();
|
||||
expect(input.undefined).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue