Giter Club home page Giter Club logo

ghcd's Introduction

ghcd

"GitHub Change Detection"

A CLI tool that enables change detection in GitHub workflows.

Modes

There are two modes offered by ghcd:

  • FilesDiff - This mode pulls a list of all files modified between two commits. Intended for CI e.g. building and testing.

  • EnvironmentDiff - This mode compares all files changed between the commit that is currently live in a GitHub environment and the commit of the currently running GitHub workflow. Intended for CD e.g. deployment.

Configuration

Configuration is provided to ghcd as a YAML file. An example ghcd.yml file that demonstrates all features is provided below:

detect:

  build-api:
    mode: FilesDiff
    paths:
      - src/api

  deploy-api:
    mode: EnvironmentDiff
    environment: production-api
    paths:
      - src/api
      - deploy/terraform/api

Paths in the configuration are relative to the current working directory when executing ghcd.

CLI Reference

An example execution of ghcd in a GitHub workflow context is provided below.

ghcd detect -f ghcd.yml --token ${{ secrets.GITHUB_TOKEN }} --repository ${{ github.repository }} --start ${{ github.event.before }} --end ${{ github.event.after }}

There is currently only one command, detect, which accepts the following flags.

Flag Required Description
f No The configuration file to use. If omitted, "ghcd.yml" is used.
token If configuration uses EnvironmentDiff mode The GitHub token to use to access the GitHub API. Used for checking what commit is in an environment.
repository If configuration uses EnvironmentDiff mode The GitHub repository.
start If configuration uses FilesDiff mode The starting commit used for comparison in FilesDiff mode. Changes made in the specified commit are not considered when checking for changes.
end Yes The end commit used for all comparisons. Changes made in the specified commit are considered when checking for changes.

Output

It is intended for ghcd to be used to produce your job outputs. Consider the following segment of a GitHub workflow:

jobs:
  change-detection:
    runs-on: ubuntu-latest
    outputs:
      build-api: ${{ steps.ghcd.outputs.build-api }}
      deploy-api: ${{ steps.ghcd.outputs.deploy-api }}
    steps:
      - id: ghcd
        run: ghcd detect --token ${{ secrets.GITHUB_TOKEN }} --repository ${{ github.repository }} --start ${{ github.event.before }} --end ${{ github.event.after }} >> "$GITHUB_OUTPUT"

If we assume the example ghcd.yml file provided above is present in the root of the repository, the change-detection job defined above will output something like the following, including the new lines:

build-api=true
deploy-api=true

The value for each pair will differ based on whether or not any changes occured in any of the provided paths, with respect to the operating mode.

For example, build-api will have true if any files changed between the start and end commits had changes with that path prefix.

Further, deploy-api will have true if there have been any changes to files with the provided path prefixes since the commit that was last deployed to the production-api environment and the end commit.

ghcd's People

Contributors

lukejoshuapark avatar

Watchers

 avatar  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.