All Projects → MarceloPrado → Has Changed Path

MarceloPrado / Has Changed Path

Licence: mit
GitHub Action that saves time and money in monorepo environments

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Has Changed Path

changed-files
Github action to retrieve all (added, copied, modified, deleted, renamed, type changed, unmerged, unknown) files and directories.
Stars: ✭ 733 (+618.63%)
Mutual labels:  ci, monorepo, workflows
Monorepo
Showcase of how to manage building projects inside monorepo with Gradle as build tool and CircleCI, Bitbucket Pipelines, Travis CI or GitHub Actions as CI tool.
Stars: ✭ 129 (+26.47%)
Mutual labels:  ci, monorepo
nrwl-nx-action
A GitHub Action to wrap Nrwl Nx commands in your workflows.
Stars: ✭ 163 (+59.8%)
Mutual labels:  monorepo, workflows
Mbt
The most flexible build tool for monorepo
Stars: ✭ 184 (+80.39%)
Mutual labels:  ci, monorepo
Baur
baur manages builds and artifacts in mono repositories
Stars: ✭ 285 (+179.41%)
Mutual labels:  ci, monorepo
Sketchpad
Sketchpad is fully customisable collaborative whiteboard plugin written in pure JavaScript.
Stars: ✭ 85 (-16.67%)
Mutual labels:  history
Github Slug Action
GitHub Action to expose slug value of GitHub environment variables inside your GitHub workflow
Stars: ✭ 96 (-5.88%)
Mutual labels:  workflows
Flow Mono Cli
A command line interface that aims to solve a few issues while working with flow typed codebases in a mono-repo.
Stars: ✭ 84 (-17.65%)
Mutual labels:  monorepo
Grand Timeline
Interactive grand unified timeline of 30,800 ancient Chinese people / 古人全表
Stars: ✭ 83 (-18.63%)
Mutual labels:  history
Orkestra
Functional DevOps with Scala and Kubernetes
Stars: ✭ 102 (+0%)
Mutual labels:  ci
Templates
YML templates
Stars: ✭ 100 (-1.96%)
Mutual labels:  ci
Github Codebuild Integration
Run and Integrate AWS CodeBuild with GitHub Push/Pull-Request webhook events.
Stars: ✭ 94 (-7.84%)
Mutual labels:  ci
Freebsd Ci
FreeBSD Continuous Integration (CI)
Stars: ✭ 85 (-16.67%)
Mutual labels:  ci
Vue Mpc
multiple pages (multiple entries) based on vue-cli3.x(基于vue-cli3.x创建的多页面应用,每个页面入口又可以创建自己的vue-router)
Stars: ✭ 97 (-4.9%)
Mutual labels:  history
Leeroyci
Leeroy is a self hosted, continuous integration and build service
Stars: ✭ 84 (-17.65%)
Mutual labels:  ci
Git History Editor
✏️ Online commit editor, intuitive and easy to use
Stars: ✭ 100 (-1.96%)
Mutual labels:  history
Lightkeeper
Run Lighthouse tests in Pull Requests for multiple URLs with custom budgets
Stars: ✭ 83 (-18.63%)
Mutual labels:  ci
Lint Diff
💅 Run eslint only in the changed parts of the code
Stars: ✭ 92 (-9.8%)
Mutual labels:  ci
Rain
🌧️ A live example to illustrate python packaging, testing, building, & deploying
Stars: ✭ 99 (-2.94%)
Mutual labels:  ci
Farce
History repeats itself
Stars: ✭ 89 (-12.75%)
Mutual labels:  history

Has Changed Path - GitHub Action

has-changed-path status

This action outputs whether a path or combination of paths has changed in the previous commit.

It solves a common issue among monorepo setups: conditional actions. Deploying a project that did not change in the previous commit could be a waste of time and resources.

With this action, you know if a deployment or any other job needs to run based on the changed paths of the most recent commit.

It differs from GitHub's paths as our action is meant to be used inside your job steps, not at the root of your workflow file (see this issue).

My recommendation is to put this action in a workflow that runs on every push to master.

Inputs

  • paths (required): Path to detect changes. It's possible to pass one path, a combination or a wildcard. Valid options include: packages/front, packages/front packages/shared, packages/**/tests. See workflow examples below for more information.

Outputs

  • changed: boolean indicating if the paths changed at the latest commit

Example workflows

Important info:

Notice that you must configure fetch-depth in your actions/[email protected]. That's because their default option now is to fetch only the latest commit instead of all history (more info)

If you want to fetch all history, pass fetch-depth: 0.

For monorepo packages, where history tends to be larger than single repos, it may take a while fetching all of it. That's why we used fetch-depth: 100 in the examples. It will fetch the latest 100 commits.

Detecting a simple one-path change:

name: Conditional Deploy

on: push

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/[email protected]
        with:
          fetch-depth: 100

      - uses: marceloprado/[email protected]
        id: changed-front
        with:
          paths: packages/front

      - name: Deploy front
        if: steps.changed-front.outputs.changed == 'true'
        run: /deploy-front.sh

Detecting changes in multiple paths:

Useful when you have dependencies between packages (eg. /common package used in /front and /server). Below, the output would be truthy for any given change inside packages/front or packages/common.

name: Conditional Deploy

on: push

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/[email protected]
        with:
          fetch-depth: 100

      - uses: marceloprado/[email protected]
        id: changed-front
        with:
          paths: packages/front packages/common

      - name: Deploy front
        if: steps.changed-front.outputs.changed == 'true'
        run: /deploy-front.sh

Detecting a one-path change with checkout multiple repos:

name: Conditional Deploy

on: push

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/[email protected]
        with:
          fetch-depth: 100
          path: main

      - uses: actions/[email protected]
        with:
          fetch-depth: 100
          repsitory: my-org/my-tools
          path: my-tools

      - uses: marceloprado/[email protected]
        id: changed-main
        with:
          paths: packages/front
        env:
          SOURCE: main

      - uses: marceloprado/[email protected]
        id: changed-my-tools
        with:
          paths: somewhere/else
        env:
          SOURCE: my-tools

      - name: Deploy main
        if: steps.changed-main.outputs.changed == 'true'
        run: /deploy-main.sh

      - name: Deploy my tools
        if: steps.changed-my-tools.outputs.changed == 'true'
        run: /deploy-my-tools.sh

How it works?

The action itself is pretty simple - take a look at src/hasChanged.js ;) .

Basically, we compare the latest HEAD with the previous one using git diff command. This allows us to effectively detect changes in most cases (squashed merges and merges with merge commit).

The algorithm works very similar with Netlify's default way for detecting changes in monorepo builds.

Contribute

Have any thoughts or suggestions? Please, open an issue and I'll be happy to improve this action!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].