{"id":13530792,"url":"https://github.com/MarceloPrado/has-changed-path","last_synced_at":"2025-04-01T19:30:40.212Z","repository":{"id":40754248,"uuid":"227914830","full_name":"MarceloPrado/has-changed-path","owner":"MarceloPrado","description":"GitHub Action that saves time and money in monorepo environments","archived":false,"fork":false,"pushed_at":"2024-06-04T11:06:12.000Z","size":261,"stargazers_count":227,"open_issues_count":7,"forks_count":33,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-23T10:42:19.750Z","etag":null,"topics":["ci","detecting-changes","history","monorepo","workflows"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarceloPrado.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-13T20:13:57.000Z","updated_at":"2025-01-09T07:22:24.000Z","dependencies_parsed_at":"2024-06-18T12:32:47.693Z","dependency_job_id":"5259f194-1c8a-49ba-ae10-4c6744746b7f","html_url":"https://github.com/MarceloPrado/has-changed-path","commit_stats":{"total_commits":28,"total_committers":7,"mean_commits":4.0,"dds":0.3571428571428571,"last_synced_commit":"e35daeb953fe58b885b07a442304243ebcc6c92a"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarceloPrado%2Fhas-changed-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarceloPrado%2Fhas-changed-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarceloPrado%2Fhas-changed-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarceloPrado%2Fhas-changed-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarceloPrado","download_url":"https://codeload.github.com/MarceloPrado/has-changed-path/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246700056,"owners_count":20819816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","detecting-changes","history","monorepo","workflows"],"created_at":"2024-08-01T07:00:55.338Z","updated_at":"2025-04-01T19:30:39.806Z","avatar_url":"https://github.com/MarceloPrado.png","language":"JavaScript","readme":"# Has Changed Path - GitHub Action\n\n\u003cp align=\"left\"\u003e\n  \u003ca href=\"https://github.com/MarceloPrado/has-changed-path/actions\"\u003e\u003cimg alt=\"has-changed-path status\" src=\"https://github.com/MarceloPrado/has-changed-path/workflows/unit-tests/badge.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nThis action outputs whether a path or combination of paths has changed in the previous commit.\n\nIt 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.\n\nWith this action, **you know if a deployment or any other job needs to run based on the changed paths of the most recent commit.**\n\nIt differs from [GitHub's paths](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#onpushpull_requestpaths) as our action is meant to be used inside your job steps, not at the root of your workflow file (see [this issue](https://github.community/t5/GitHub-Actions/Path-filtering-for-jobs-and-steps/td-p/33617)).\n\nMy recommendation is to put this action in a workflow that runs on every push to `master`.\n\n## Inputs\n\n- `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.\n\n## Outputs\n\n- `changed`: boolean indicating if the paths changed at the latest commit\n\n## Example workflows\n\n### Important info:\n\nNotice that **you must configure `fetch-depth` in your `actions/checkout@v2`**. That's because their default option now is to fetch only the latest commit instead of all history ([more info](https://github.com/actions/checkout))\n\nIf you want to fetch all history, pass `fetch-depth: 0`.\n\nFor 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.\n\n### Detecting a simple one-path change:\n\n```yaml\nname: Conditional Deploy\n\non: push\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@v2\n        with:\n          fetch-depth: 100\n\n      - uses: marceloprado/has-changed-path@v1.0.1\n        id: changed-front\n        with:\n          paths: packages/front\n\n      - name: Deploy front\n        if: steps.changed-front.outputs.changed == 'true'\n        run: /deploy-front.sh\n```\n\n### Detecting changes in multiple paths:\n\nUseful when you have dependencies between packages (eg. `/common` package used in `/front` and `/server`).\nBelow, the output would be truthy for any given change inside `packages/front` **or** `packages/common`.\n\n```yaml\nname: Conditional Deploy\n\non: push\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@v2\n        with:\n          fetch-depth: 100\n\n      - uses: marceloprado/has-changed-path@v1.0.1\n        id: changed-front\n        with:\n          paths: packages/front packages/common\n\n      - name: Deploy front\n        if: steps.changed-front.outputs.changed == 'true'\n        run: /deploy-front.sh\n```\n\n### Detecting a one-path change with checkout multiple repos:\n\n```yaml\nname: Conditional Deploy\n\non: push\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@v2\n        with:\n          fetch-depth: 100\n          path: main\n\n      - uses: actions/checkout@v2\n        with:\n          fetch-depth: 100\n          repsitory: my-org/my-tools\n          path: my-tools\n\n      - uses: marceloprado/has-changed-path@v1.0.1\n        id: changed-main\n        with:\n          paths: packages/front\n        env:\n          SOURCE: main\n\n      - uses: marceloprado/has-changed-path@v1.0.1\n        id: changed-my-tools\n        with:\n          paths: somewhere/else\n        env:\n          SOURCE: my-tools\n\n      - name: Deploy main\n        if: steps.changed-main.outputs.changed == 'true'\n        run: /deploy-main.sh\n\n      - name: Deploy my tools\n        if: steps.changed-my-tools.outputs.changed == 'true'\n        run: /deploy-my-tools.sh\n```\n\n## How it works?\n\nThe action itself is pretty simple - take a look at [`src/hasChanged.js`](https://github.com/MarceloPrado/has-changed-path/blob/master/src/hasChanged.js) ;) .\n\nBasically, 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).\n\nThe algorithm works very similar with [Netlify's default way](https://community.netlify.com/t/monorepo-and-long-builds/7234/2) for detecting changes in monorepo builds.\n\n## Contribute\n\nHave any thoughts or suggestions? Please, open an issue and I'll be happy to improve this action!\n","funding_links":[],"categories":["JavaScript","Community Resources"],"sub_categories":["Utility"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMarceloPrado%2Fhas-changed-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMarceloPrado%2Fhas-changed-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMarceloPrado%2Fhas-changed-path/lists"}