Giter Site home page Giter Site logo

candidco / libyear-node-action Goto Github PK

View Code? Open in Web Editor NEW

This project forked from s0/libyear-node-action

0.0 0.0 0.0 1.1 MB

Track NPM dependency freshness, and calculate how pull requests will impact this

License: GNU General Public License v3.0

JavaScript 2.74% TypeScript 97.26%

libyear-node-action's Introduction

Node dependency libyear stats & PR checks

codecov

This GitHub Action will allow you to track how well a repository is keeping up-to-date with NPM dependencies, using libyear.

This action is powered by the NPM package by the same name: libyear.

It can be used in combination with other actions to generate badges (see below).

Usage

Simply include the action s0/libyear-node-action in the appropriate point in your workflow, and pass in the required configuration options:

Note: For best results, it is recommended you install your NPM using your preferred package manager before running this action

**Note: We recommend using the latest release rather than develop to avoid future breaking changes with your workflow.

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest
    steps:

    # Any prerequisite steps
    - uses: actions/checkout@master
    - run: npm install

    # Calculate libyear
    - uses: s0/libyear-node-action@develop

Configuration

All configuration options are passed in via env, as environment variables. For example:

jobs:
  deploy:
    # ...
    - uses: s0/libyear-node-action@develop
      env:
        FOLDER: some/sub/directory

Full list of variables

Env Variable Description Required?
FOLDER Which directory within your repository should libyear be run in. (Default: root of repository) No

Outputs

This action generates outputs that can be used in later steps or outputs (for example to generate badges to display in your README, see below).

The following outputs are generated. Each of them represents a metric from libyear.

Output Description
drift A floating-point number with 2 decimal places
pulse A floating-point number with 2 decimal places
releases An integer
major An integer
minor An integer
patch An integer

Example: Generating badges using libyear stats

Here's an example workflow that will generate a badge for you and push it to a special branch that can be referenced in e.g. your README. It uses the actions emibcn/badge-action and s0/git-publish-subdir-action in addition to this action.

name: Generate Badges
on:
  # Run on pushes to your main branch
  push:
    branches:
      - develop
  # Run every day
  schedule:
    - cron: "0 0 * * *"

jobs:
  get-badges:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Use Node.js
      uses: actions/setup-node@v4
      with:
        node-version: 20.x

    # Install dependencies and run libyear
    # (notice how the libyear step has an id, this is referenced later)
    - run: npm install
    - id: libyear
      uses: s0/libyear-node-action@develop

    # Generate a badge and store it in the badge/directory
    - run: mkdir badges
    - uses: emibcn/badge-action@v1
      with:
        label: 'libyear'
        # Here is where we use the output from the libyear step
        status: ${{ steps.libyear.outputs.drift }} year(s) behind
        color: 'blue'
        path: 'badges/drift.svg'

    # Upload the directory "badge" as a branch "badge" on the same repo
    - uses: s0/git-publish-subdir-action@develop
      env:
        REPO: self
        BRANCH: badges
        FOLDER: badges
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        SQUASH_HISTORY: true

We use this for this repository, you can see the workflow here: badges.yml

TODO

Please see the issues for details of planned work.

libyear-node-action's People

Contributors

s0 avatar tacrocha avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.