Taction is a CLI utility to make authoring GitHub Actions easier and more type-safe. It parses an action.yml file and generates typescript types for the inputs and outputs. More commands may be added in the future.
npm install -g taction
# or
yarn global add taction
# or
pnpm add -g tactionnpm install --save-dev taction
# or
yarn add --dev taction
# or
pnpm add --dev tactionnpx taction types ./action.yml ./src/typed-core.ts
# or
pnpm dlx taction types ./action.yml ./src/typed-core.tsParse an action.yml file and generate typescript types for the inputs and outputs
taction types action.yml typed-core.tsinfile: path of action.yml file to parseoutfile: path of typed core file to output
Import the typed core in your typescript file and use it instead of the core module. The keys will now be typed and will error out if you misspell a key or try to use one that is not an input or output.
import typedCore from "./typed-core";
const myInput = typedCore.getInput("myInput");
const myBooleanInput = typedCore.getBooleanInput("myBooleanInput");
typedCore.setOutput("myOutput", "value");The typed core is a wrapper of the core module with the following modifications:
getInput(inputName: StringInputs): stringgetBooleanInput(inputName: BooleanInputs): booleangetNumberInput(inputName: StringInputs): numbergetChoiceInput<T extends keyof IChoiceInputs>(inputName: T): IChoiceInputs[T]setOutput(outputName: Outputs, value: any)
StringInputs and BooleanInputs are the union of all the inputs that are strings and booleans respectively.
IChoiceInputs is an interface with the keys of all the choice inputs and the types for the keys are the union of all the options for that input.
Outputs is the union of all the outputs.
MIT © Chris Griffing