npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jet-snowman/elastic-github-actions

v3.0.0

Published

Generate GitHub Actions Workflow files using TypeScript (compiles to YAML)

Downloads

978

Readme

Elastic GitHub Actions

Share your configs and steps between workflows. No classes and zero learning curve.

Installation

npm install @jet-snowman/elastic-github-actions

Overview

Leveraging TypeScript's flexibility enables seamless inclusion and sharing of entities across multiple files, eliminating redundancies and providing autocomplete for permitted settings in GitHub Actions.

Getting Started

npx jet-ega
Usage: jet-ega [options] [command]

Generate GitHub Actions Workflow files using TypeScript (compiles to YAML and backward)

Options:
  -V, --version   output the version number
  -h, --help      display help for command

Commands:
  init            Creates a config file
  tsToYaml        Compiles TS files to YAMLs
  yamlToTs        Compiles YAMLs to TS files
  help [command]  display help for command
npx jet-ega init

It creates jet-ega.config.json config file with the following structure:

{
  "ts": {
    "entry": "./examples/ts/index.ts",
    "output": "./output/yaml"
  },
  "yaml": {
    "folder": "./examples/yaml",
    "output": "./output/ts"
  }
}

You have the flexibility to specify the entry TypeScript file for generating GitHub Action workflow YAML files. Moreover, it offers the ability to effortlessly convert existing YAML files into TypeScript files.

When you are done with the config file.

TS files to YAML files

npx jet-ega tsToYaml

OR

YAML files to TS files

npx jet-ega yamlToTs

Simple Example

import { registerWorkflow } from '@jet-snowman/elastic-github-actions';

registerWorkflow({
  name: 'tests',
  'run-name': 'Testing ${{ inputs.deploy_target }} by @${{ github.actor }}',
  on: 'push',
  jobs: {
    'my-test': {
      'runs-on': 'ubuntu-latest',
      'timeout-minutes': 30,
      strategy: {
        matrix: {
          'node-version': [
            '20.x'
          ],
          'mongodb-version': [
            '7.0'
          ],
          'redis-version': [
            '7.0'
          ]
        }
      },
      steps: [
        {
          name: 'Get branch name (merge)',
          'if': 'github.event_name != \'pull_request\'',
          shell: 'bash',
          run: 'echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV'
        },
        {
          name: 'Branch name',
          run: 'echo ${{ env.BRANCH_NAME }}'
        }
      ]
    }
  }
});

Advanced Example

import { NormalJob, registerWorkflow, toMultiRun } from '@jet-snowman/elastic-github-actions';

interface AwsService {
  id: string;
  name: string;
  env: string;
  taskFile: string;
  service: string;
}

const apiService: AwsService = {
  id: 'task-api-def',
  name: 'API',
  env: 'API_TASK',
  taskFile: 'api.json',
  service: 'api',
};

const jobs: { deploy: NormalJob } = {
  deploy: {
    'runs-on': 'ubuntu-latest',
    'timeout-minutes': 30,
    strategy: {
      matrix: {
        region: [
          'us-west-2'
        ]
      }
    },
    steps: []
  }
};

//download tasks
const tasks: string[] = [];
for (const service of services) {
  tasks.push(`aws ecs describe-task-definition --task-definition $${service.env} --query taskDefinition > ${service.taskFile}`);
}

jobs.deploy.steps.push({
  name: 'Download task definitions',
  run: tasks.join('\n') + '\n'
});

registerWorkflow({
  name: 'deploy',
  'run-name': 'Deploying to AWS by @${{ github.actor }}',
  on: {
    push: {
      branches: [
        'production'
      ]
    },
    workflow_run: {
      branches: [
        'staging',
        'production'
      ],
      types: [
        'completed'
      ]
    }
  },
  concurrency: {
    group: '${{ github.workflow }}-${{ github.ref }}',
    'cancel-in-progress': true
  },
  jobs
});

With TypeScript, you can seamlessly organize your code the way you want or integrate it into your existing project without any hassles

Helpers

toMultiRun() - aids in writing multiline yaml like this:

name: Test
run: |
  command 1
  command 2

License

This project is licensed under the MIT License