@infra-blocks/github-actions

0.3.5 • Public • Published

ts-github-actions

Build Release Update From Template codecov

This package provides a set of utilities to improve developer UX while writing GitHub Actions in Typescript.

Usage

The entrypoint to a GitHub Action should look like this:

import { getInputs, runActionHandler } from "@infra-blocks/github-actions";
// You are free to use your favorite validation library. We like zod.
import { z } from "zod";

interface Outputs {
  "example-output": string;
}

async function handler(config: {exampleInput: string; bigInput: number}): Promise<Outputs> {
  // The business goes here.
}

runActionHandler(() => {
  const inputs = getInputs("example-input", "bigInput");
  const config = z.object({
    "example-input": z.string(),
    bigInput: z.number()
  }).transform((parsed) => ({
    exampleInput: parsed["example-input"],
    bigInput: parse.bigInput
  })).parse(inputs);
  return handler(config);
});

Package Sidebar

Install

npm i @infra-blocks/github-actions

Weekly Downloads

253

Version

0.3.5

License

ISC

Unpacked Size

23.1 kB

Total Files

9

Last publish

Collaborators

  • phil-lavoie