Skip to content

Commit 9898c72

Browse files
authored
feat: specify separate targets for dev and production (#572)
* feat: add additional target options for dev and production dependencies * feat: adjust for proper naming and priority of target-* values * feat: add tests for target-* changes * fix: refactor logic and improve documentation
1 parent 18a935d commit 9898c72

File tree

6 files changed

+1672
-1435
lines changed

6 files changed

+1672
-1435
lines changed

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,24 @@ Error: Resource not accessible by integration
2121
## Inputs
2222

2323
| input | required | default | description |
24-
|----------------------------|----------|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
24+
| -------------------------- | -------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2525
| `github-token` | No | `${{github.token}}` | A GitHub token. |
2626
| `exclude` | No | | A comma or semicolon separated value of packages that you don't want to auto-merge and would like to manually review to decide whether to upgrade or not. |
2727
| `approve-only` | No | `false` | If `true`, the PR is only approved but not merged. |
2828
| `merge-method` | No | `squash` | The merge method you would like to use (squash, merge, rebase). |
2929
| `merge-comment` | No | `''` | An arbitrary message that you'd like to comment on the PR after it gets auto-merged. This is only useful when you're receiving too much of noise in email and would like to filter mails for PRs that got automatically merged. |
3030
| `use-github-auto-merge` | No | `false` | If `true`, the PR is marked as auto-merge and will be merged by GitHub when status checks are satisfied.<br /><br />_NOTE_: This feature only works when all of the following conditions are met.<br />- The repository enables auto-merge. <br />- The pull request base must have a branch protection rule. <br />- The pull request's status checks are not yet satisfied.<br /></br>Refer to [the official document](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/automatically-merging-a-pull-request) about GitHub auto-merge. |
3131
| `target` | No | `any` | A flag to only auto-merge updates based on Semantic Versioning.<br />Possible options are: `major, premajor, minor, preminor, patch, prepatch, prerelease, any`.<br /><br />The value of this flag allows for updates for all the matching versions **and lower** with the respect for priority. This means, for example, if the `target` is set to `major` and the update is made to `minor` version the auto-merge will be triggered.<br /><br />For more details on how semantic version difference is calculated please see [semver](https://www.npmjs.com/package/semver) package.<br /><br />If you set a value other than `any`, PRs that are not semantic version compliant are skipped. An example of a non-semantic version is a commit hash when using git submodules. |
32+
| `target-development` | No | | Same as `target` but specifies semver for `development` dependencies only. If present, then it overrides the value in `target` for `development` dependencies. |
33+
| `target-production` | No | | Same as `target` but specifies semver for `production` dependencies only. If present, then it overrides the value in `target` for `production` dependencies. |
3234
| `pr-number` | No | | A pull request number, only required if triggered from a workflow_dispatch event. Typically this would be triggered by a script running in a separate CI provider. See [Trigger action from workflow_dispatch event](#trigger-action-from-workflow_dispatch-event) example. |
3335
| `skip-commit-verification` | No | `false` | If `true`, then the action will not expect the commits to have a verification signature. It is required to set this to `true` in GitHub Enterprise Server. |
3436
| `skip-verification` | No | `false` | If true, the action will not validate the user or the commit verification status |
3537

3638
## Output
3739

3840
| outputs | Description |
39-
|---------------|---------------|
41+
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
4042
| merge_status | The result status of the merge. It can be one of the following: `approved`, `merged`, `merge_failed`, `skipped:commit_verification_failed`, `skipped:not_a_dependabot_pr`, `skipped:cannot_update_major`, `skipped:bump_higher_than_target`, `skipped:packaged_excluded` |
4143

4244
## Examples
@@ -93,6 +95,27 @@ steps:
9395
approve-only: true
9496
```
9597
98+
### Specifying target versions
99+
100+
#### Specifying target for all packages
101+
102+
```yml
103+
steps:
104+
- uses: fastify/github-action-merge-dependabot@v3
105+
with:
106+
target: 'minor'
107+
```
108+
109+
#### Specifying target for development and production packages separately
110+
111+
```yml
112+
steps:
113+
- uses: fastify/github-action-merge-dependabot@v3
114+
with:
115+
target-development: 'major'
116+
target-production: 'minor'
117+
```
118+
96119
### Trigger action from workflow_dispatch event
97120
98121
If you need to trigger this action manually, you can use the [`workflow_dispatch`](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch) event. A use case might be that your CI runs on a seperate provider, so you would like to run this action as a result of a successful CI run.
@@ -131,7 +154,6 @@ curl -X POST \
131154
-d '{"ref":"{ref}", "inputs":{ "pr-number": "{number}"}}'
132155
```
133156

134-
135157
## How to upgrade from `2.x` to new `3.x`
136158

137159
- Update the action version.
@@ -141,7 +163,6 @@ curl -X POST \
141163
- Remove the `api-url` option from your workflow.
142164
- Turn off the [`dependabot-merge-action-app`](https://github.com/fastify/dependabot-merge-action-app/) application.
143165

144-
145166
Migration example:
146167

147168
```diff

action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@ inputs:
2626
required: false
2727
default: false
2828
target:
29-
description: 'Auto-merge on major, minor, patch updates based on Semantic Versioning'
29+
description: 'Auto-merge on updates based on Semantic Versioning'
3030
required: false
3131
default: 'any'
32+
target-development:
33+
description: 'Auto-merge on updates based on Semantic Versioning for development dependencies'
34+
required: false
35+
target-production:
36+
description: 'Auto-merge on updates based on Semantic Versioning for production dependencies'
37+
required: false
3238
pr-number:
3339
description: 'A pull request number, only required if triggered from a workflow_dispatch event'
3440
required: false

0 commit comments

Comments
 (0)