You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+65-11Lines changed: 65 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Organization Projects' Dependency Manager
2
-
GitHub Action that handles automated update of dependencies in package.json between projects from the same GitHub organization. You run this workflow after npm package release. It searches for libraries in your GitHub organization that depend on this package and bump version through a PR flow.
2
+
GitHub Action that handles automated update of dependencies in package.json between projects from the same GitHub organization. You run this workflow after npm package release. It searches for libraries in your GitHub organization that depend on the released packages and creates pull requests with updated dependencies.
3
3
4
4
While updating multiple repositories, if there are issues with one of them, the action doesn't fail but continues bumping deps in next repo from the list.
5
5
@@ -28,15 +28,17 @@ You cannot apply monorepo everywhere, sometimes it doesn't make sense, and you s
28
28
29
29
tl;dr To find dependent projects, GitHub Search is utilized.
30
30
31
-
Before you run this action, I suggest you first use manually the search query used by this action. Go to https://github.com and in search box paste `"@myorg/test" user:myorg in:file filename:package.json` (with proper names of course). Identify repositories that have your package in dependencies, but you do not want to automatically update it. Add it to the list of ignored repositories
31
+
Before you run this action, I suggest you first use manually the search query used by this action. Go to https://github.com and in search box paste `"@myorg/test" user:myorg path:package.json` (with proper names of course). Identify repositories that have your package in dependencies, but you do not want to automatically update it. Add it to the list of ignored repositories
32
32
33
-
1. You run this action in package `@myorg/test`
34
-
1. After releasing `@myorg/test`, you want latest version of the package to be bumped in other packages in your organization/user called `myorg`
35
-
1. The following search is performed `"@myorg/test" user:myorg in:file filename:package.json`
36
-
1. Search is not perfect, quotations from `"@myorg/test"` are ignored and result can also contain repositories that have only `@myorg/test-sdk` as dependency
37
-
1. All found repositories are cloned (except of `@myorg/test`)
38
-
1. Action verifies if you really have `@myorg/test` in dependencies or devDependencies
39
-
1. Now the rest, bumping + pushing + creating a pull request
33
+
1. You run this action in some repository after releasing a package, let's say `test-packages` in organization `myorg`.
34
+
1. If search is set to false (default), only the package.json from the root or from the provided path is processed. If search is set to true, all package.json files are searched using `repo:myorg/test-packages in:file filename:package.json` query and the following processing steps are applied for each of them:
35
+
1. The package name and version are read from the package.json file in which the action is running, let's say `@myorg/test` with version `1.0.1`
36
+
1. The following search is performed `"@myorg/test" user:myorg in:file filename:package.json` (GitHub still uses the Legacy API for search, so `path:` doesn't work, we need to use `filename:` instead)
37
+
1. Search is not perfect, quotations from `"@myorg/test"` are ignored and result can also contain repositories that have only `@myorg/test-sdk` as dependency
38
+
1. All found repositories are cloned (except of `@myorg/test`)
39
+
1. Action verifies if you really have `@myorg/test` in dependencies or devDependencies
40
+
1. Action checks the package.json to see the package manager used (npm, yarn, pnpm or bun) and runs proper install command.
41
+
1. Now the rest, bumping + pushing + creating a pull request
40
42
41
43
Approach with using GitHub search has only one disadvantage, bumping will not work in forks, as forks do not show up in search results. It is still better than cloning all repositories from your organization.
42
44
@@ -46,21 +48,43 @@ I provided only unit tests for essential utils. There are no integration tests a
A -- No --> B[Pick name and version from root package.json]
56
+
A -- Yes --> C[Search for all package.json files in repo and read name + version for each]
57
+
C --> D[Get list of repos from GitHub search that have dependency in their package.json]
58
+
B --> D
59
+
60
+
subgraph Repo Processing Loop
61
+
D --> E[For each repo: Clone if not ignored and create new branch]
62
+
E --> F[Verify dependency type dependency or devDependency]
63
+
F --> G[Detect and choose package manager from: `npm, yarn, pnpm, bun`]
64
+
G --> H[Bump version locally]
65
+
H --> I[Push changes and open PR]
66
+
I --> E
67
+
end
68
+
end
69
+
I --> J[Autoapprove and Automerge PR]
70
+
71
+
```
50
72
51
73
## Configuration
52
74
53
75
Name | Description | Required | Default
54
76
--|------|--|--
55
77
github_token | Token to use GitHub API. It must have "repo" scopes so it can push to repos. It cannot be the default GitHub Actions token GITHUB_TOKEN. GitHub Action token's permissions are limited to the repository that contains your workflows. Provide token of the user that has rights to push to the repos that this action is suppose to update. | true | -
56
-
packagejson_path | Path to package.json file if not located in the root of the project. Provide just the path without file name. In the format: `./nested/location`. | false | `./`
78
+
packagejson_path | Paths to package.json file if not located in the root of the project. Provide just the paths without file name. In the format: `./nested/location`. You can provide single or multiple paths separated by commas. | false | `./`
57
79
committer_username | The username (not display name) of the committer will be used to commit changes in the workflow file in a specific repository. In the format `web-flow`. | false | `web-flow`
58
80
committer_email | The committer's email that will be used in the commit of changes in the workflow file in a specific repository. In the format `[email protected]`.| false | `[email protected]`
59
81
commit_message_prod | It is used as a commit message when bumping dependency from "dependencies" section in package.json. In case dependency is located in both dependencies and devDependencies of dependant, then prod commit message is used. It is also used as a title of the pull request that is created by this action. | false | `fix: update ${dependencyName} to ${dependencyVersion} version`
60
82
commit_message_dev | It is used as a commit message when bumping dependency from "devDependencies" section in package.json. It is also used as a title of the pull request that is created by this action. | false | `chore: update ${dependencyName} to ${dependencyVersion} version`
61
83
repos_to_ignore | Comma-separated list of repositories that should not get updates from this action. Action already ignores the repo in which the action is triggered so you do not need to add it explicitly. In the format `repo1,repo2`. | false | -
62
84
base_branch | Name of the base branch, where changes in package.json must be applied. It is used in PR creation. Branch where changes are introduced is cut from this base branch. If not provided, default branch is used. In the format: `next-major`. | false | -
63
85
custom_id | This custom_id is added as a unique identifier value to the PR created by the bot so the bot can later recognize it as created by the bot, so it updates existing PR instead creating new one. If custom_id is not specified, action assumes that you still want bot to create multiple PRs in one repo, with multiple updates. Once you add the custom_id, you enable flow with active one PR per repo | false | -
86
+
search | In case you have multiple packages.json files in repository and you want to update by searching for all of them. This is useful for monorepos. **Note: Enabling `search` overrides the list of paths provided.** | false | `false` (only root package.json is updated)
87
+
ignore_paths | Comma-separated list of paths to **directories** to ignore when searching for package.json files if `search` is set to true. In the format: `./path/to/ignore,./another/path/to/ignore`. | false | -
64
88
65
89
## Example
66
90
@@ -95,6 +119,31 @@ jobs:
95
119
commit_message_dev: "chore: update internal development dependencies"
96
120
```
97
121
122
+
### Multiple package.json files
123
+
124
+
In case you have multiple package.json files in your repository and you want to update them all, you can provide comma-separated list of paths to `packagejson_path` input.
In case you have multiple package.json files in your repository and you want to update by searching for all of them, enable `search` input. You can specify ignore paths to exclude certain directories from the search. This is useful for monorepos. Note: Enabling `search` overrides the list of paths provided.
# LOCAL_REPO_PATH=../test is the path to be appended to all the searched package.json files in case you want to test multiple package.json files in one repo
In case something ain't right, the action doesn't work as expected, enable debugging. Add to **Secrets** of the repository a secret called `ACTIONS_STEP_DEBUG` with value `true`. Now, once you run the action again, there will be additional logs visible that start with `DEBUG: `.
Copy file name to clipboardExpand all lines: action.yml
+11-1Lines changed: 11 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ inputs:
37
37
required: false
38
38
packagejson_path:
39
39
description: >
40
-
Path to package.json file if not located in the root of the project. Provide just the path without file name. In the format: `./nested/location`.
40
+
Paths to package.json file if not located in the root of the project. Provide just the paths without file name. In the format: `./nested/location` or as a comma-separated list for multiple paths `./path1,./path2`.
41
41
default: ./
42
42
required: false
43
43
repos_to_ignore:
@@ -51,6 +51,16 @@ inputs:
51
51
Name of the base branch, where changes in package.json must be applied. It is used in PR creation. If not provided, default branch is used
52
52
In the format: `next-major`.
53
53
required: false
54
+
search:
55
+
description: >
56
+
Whether to search for multiple package.json files in the repository. Useful for monorepos. Note: Enabling `search` overrides the list of paths provided.
57
+
required: false
58
+
default: "false"
59
+
ignore_paths:
60
+
description: >
61
+
Comma-separated list of paths/directories that should be ignored when searching for package.json files. Only used if search input is set to true.
62
+
In the format: `./path/to/ignore,./another/path/to/ignore`.
0 commit comments