0.0.3 • Published 5 years ago
actions-inputs v0.0.3
Actions Inputs
GitHub Actions Auto generate and use input parameters in TypeScript
Main goal of this module is to auto-generate type-safe code for working with GitHub Actions inputs.
Use it in Your Action
- Install it 
yarn|npm add actions-inputs - Fill 
action.ymlwith input parameters like this: 
inputs:
  # You can also use uppercase here. It doesn't really matter.
  COMMIT_MESSAGE:
    description: |
      The commit message that will be used to commit the changed files. Check the README for all interpolation options.
    # if input isn't provided, Action runner will pick default value even if required is true
    default: "auto-update: replace files from source"
    required: false
  DRY_RUN:
    # specify type explicity here if it isn't a string and you don't have default value
    description: |
      [boolean] Run everything except for the copying, removing and commiting functionality.
    required: true
  RETRIES:
    description:
      [number] The number of retries.
    # You can specify string in default, it will be parsed to number anyway.
    default: 3
    required: false- Define 
postinstallscript inpackage.json: 
{
    "scripts": {
        //...
        "postinstall": "actions-inputs generate"
    }
}- Run 
postinstallscript oryarn actions-inputs generatecommand in order to generate library so that you can safely use it in your code. You need to run this command every time after you editaction.yml. - Use it in your code:
 
import { inputs } from "actions-inputs";
inputs.dry_run
// => boolean
inputs.retries
// => 3 (if user doesn't provide their value)Temporary Limitations
- TypeScript is used to generate library. It's in regular dependencies.
 - You need to manually generate library in 
postinstallscript. 
Things to Note
- Passing an empty string is the same as not passing anything.
 
Options
You can set options before first getInput call.
List of options: interface Options.
Possible Types
By default the type infers from input's default property, but if it's required and not a string, you need to specify type in start of description like this: description: [boolean] should I show you a red light?.
- string Any value treats as valid
 - boolean Valid: 
true,false,0,1 - number Valid: 
54.33,Infinity. Invalid:5 px 
TODO
- Auto generate type 
inputsedit inaction.yml(show warning onmain) - Use main-dev Action deploy system (remove required)
 - Describe Files Structure and does it work. Why some ts files in src why some in src etc.
 - Testsss
 - Add --watch options
 - StringArray type