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

@allejo/gha-workflows

v0.0.1

Published

A super simple script to manage building Workflows for GitHub Actions

Downloads

15

Readme

@allejo/gha-workflows

GitHub Actions does not support YAML anchors and it is incredibly annoying when it comes to reusing anything within those YAML files. So this is a stupid simple script that will expand YAML references and allow you to, sigh, compile your workflows.

This project was inspired by mithro's actions-includes project but it doesn't introduce any custom syntax. I also needed this in my JavaScript project pipelines and I did not want to setup Python just for that script.

At its core, this project is powered by js-yaml.

Example

Source YAML

name: Deployment

on:
  push:
    branches:
      - master
      - develop

jobs:
  production:
    name: Production Deployment
    runs-on: ubuntu-latest
    if: ${{ github.ref == 'refs/heads/master' }}
    environment:
      name: Production
      url: https://example.com/product
    steps: &production_steps
      - uses: actions/checkout@v2

  staging:
    name: Staging Deployment
    runs-on: ubuntu-latest
    if: ${{ github.ref == 'refs/heads/develop' }}
    environment:
        name: Staging
        url: https://staging.example.com/product

    # Handled via the `gha-workflows` CLI since GHA doesn't support YAML anchors
    #   see https://github.community/t/support-for-yaml-anchors/16128
    steps: *production_steps

Output YAML

name: Deployment
'on':
  push:
    branches:
      - master
      - develop
jobs:
  production:
    name: Production Deployment
    runs-on: ubuntu-latest
    if: ${{ github.ref == 'refs/heads/master' }}
    environment:
      name: Production
      url: https://example.com/product
    steps:
      - uses: actions/checkout@v2
  staging:
    name: Staging Deployment
    runs-on: ubuntu-latest
    if: ${{ github.ref == 'refs/heads/develop' }}
    environment:
        name: Staging
        url: https://staging.example.com/product
    steps:
      - uses: actions/checkout@v2

Installation

Use it Once

npx @allejo/gha-workflows

As a Dependency

npm install --save-dev @allejo/gha-workflows
# or
yarn add --dev @allejo/gha-workflows

CLI Usage

usage: gha-workflows.js [-h] [-v] [-c COMMENTS] [-s SOURCE] [-d DESTINATION]

A super simple script to manage building Workflows for GitHub Actions

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -c COMMENTS, --comments COMMENTS
                        Add a header comment
  -s SOURCE, --source SOURCE
                        The source directory YAML files or single YAML file that will be "compiled"
  -d DESTINATION, --destination DESTINATION
                        The output directory where "compiled" YAML files will be written to
  • The SOURCE will be the file or folder where the "source" YAML files (i.e. those with anchors and references) are located.
  • The DESTINATION file or folder will be where the compiled/flattened YAML file is written to. This should usually inside of .github/workflows/.
  • The COMMENTS value, which accepts \n, will be comments added to the top of the outputted YAML files; useful for adding warnings not to edit a generated file.

Inside of package.json

In the spirit of JS stuffing literally everything into package.json, you can use the gha-workflows key to configure this utility.

{
  "name": "my-simple-app",
  // ...
  "gha-workflows": {
    "source": ".github/workflows-src",
    "destination": ".github/workflows",
    "comments": [
      "DO NOT EDIT MANUALLY. THIS FILE IS AUTOMATICALLY GENERATED.",
      "Edit the source files in `.github/workflows-src/`"
    ]
  }
}
  • The comments key can be either a string with newlines, or an array of strings.