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
+39-39Lines changed: 39 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,11 @@ This is a [GitHub Action](https://help.github.com/en/categories/automating-your-
4
4
5
5
## Available Automations
6
6
7
-
| Automation | Description |
8
-
| ---- | --------------|
9
-
|[todos](./lib/automations/todos/README.md)| This automation parses for `@todo` or `@TODO` comments in code and adds formatted pull request comments for each todo found. When a pull request is merged to the main branch, issues will be created for each `@todo` in the diff if there is not already an issue for that todo. |
10
-
| [release](./lib/automations/release/README.md) | This automation handles automating various parts of a somewhat opinionated release process.
|[todos](./lib/automations/todos/README.md)| This automation parses for `@todo` or `@TODO` comments in code and adds formatted pull request comments for each todo found. When a pull request is merged to the main branch, issues will be created for each `@todo` in the diff if there is not already an issue for that todo. |
10
+
|[release](./lib/automations/release/README.md)| This automation handles automating various parts of a somewhat opinionated release process. |
11
+
|[assign-milestone](./lib/automations/assign-milestone/README.md)| This automation will assign the next milestone to a pull request once it has been approved. |
11
12
12
13
## Installation and Usage
13
14
@@ -16,22 +17,22 @@ To use the action, include it in your workflow configuration file:
16
17
```yaml
17
18
on: pull_request
18
19
jobs:
19
-
pull-request-automation:
20
-
runs-on: ubuntu-latest
21
-
steps:
22
-
- uses: woocommerce/automations@v1
23
-
with:
24
-
github_token: ${{ secrets.GITHUB_TOKEN }}
25
-
# This can be a comma delimited list of automations to run, in this case we're just executing todos
26
-
automations: todos
20
+
pull-request-automation:
21
+
runs-on: ubuntu-latest
22
+
steps:
23
+
- uses: woocommerce/automations@v1
24
+
with:
25
+
github_token: ${{ secrets.GITHUB_TOKEN }}
26
+
# This can be a comma delimited list of automations to run, in this case we're just executing todos
27
+
automations: todos
27
28
```
28
29
29
30
## API
30
31
31
32
### Inputs
32
33
33
-
- `github_token`: Required. GitHub API token to use for making API requests. This should be stored as a secret in the GitHub repository.
34
-
- `automations`: Optional. You can include a comma-delimited list of specific automations you want to run if you don't want to use them all in a given workflow.
34
+
- `github_token`: Required. GitHub API token to use for making API requests. This should be stored as a secret in the GitHub repository.
35
+
- `automations`: Optional. You can include a comma-delimited list of specific automations you want to run if you don't want to use them all in a given workflow.
35
36
36
37
### Outputs
37
38
@@ -43,41 +44,41 @@ This will be expanded, but for reference:
43
44
44
45
### Developing
45
46
46
-
- Clone the repo and then `npm install`.
47
+
- Clone the repo and then `npm install`.
47
48
48
49
### Builds and releases
49
50
50
-
- All pushes to trunk will automatically build the `dist/index.js` file for the action (then commit and push to trunk). So no need to worry about builds.
51
-
- For releases, make sure you update the examples in the `README.md` if releasing a major version, otherwise just create a release manually (in the future this may get automated for releases).
51
+
- All pushes to trunk will automatically build the `dist/index.js` file for the action (then commit and push to trunk). So no need to worry about builds.
52
+
- For releases, make sure you update the examples in the `README.md` if releasing a major version, otherwise just create a release manually (in the future this may get automated for releases).
52
53
53
54
### Adding a new automation.
54
55
55
56
The design of this repository is setup so that automations can be their own discrete thing (eg. "todos") but still take advantage of various scaffolding and boilerplate when creating a new automation. The following is a rough list of steps to take to create and add a new automation:
56
57
57
-
- Create a new directory in `lib/automations` that is the name of your automation.
58
-
- Your `lib/automations` directory must at a minimum export the following from the `index.js` file in the directory:
58
+
- Create a new directory in `lib/automations` that is the name of your automation.
59
+
- Your `lib/automations` directory must at a minimum export the following from the `index.js` file in the directory:
59
60
60
61
```js
61
62
module.exports = {
62
-
// the name of your automation
63
-
name: 'my-automation',
64
-
// what github action workflow events your automation reacts to.
65
-
events: ['pull_request'],
66
-
// what github action workflow event actions your automation reacts to.
67
-
actions: ['opened'],
68
-
// the runner for your automation.
69
-
runner
70
-
}
63
+
// the name of your automation
64
+
name: 'my-automation',
65
+
// what github action workflow events your automation reacts to.
66
+
events: ['pull_request'],
67
+
// what github action workflow event actions your automation reacts to.
68
+
actions: ['opened'],
69
+
// the runner for your automation.
70
+
runner,
71
+
};
71
72
```
72
-
- As noted above, this export must include a `runner` for your automation. The runner is an async function that will receive two arguments: `context`(which is the GitHub action context value) and `octokit` (which is the GitHub api helper). See more about these two arguments [here](https://github.com/actions/toolkit/tree/trunk/packages/github) (they are essentially what gets exposed by the `@actions/github` package). You can use the [`todos` runner as an example](https://github.com/woocommerce/automations/blob/trunk/lib/automations/todos/runner.js).
73
-
- Finally, in [`lib/automations.js`](https://github.com/woocommerce/automations/automations/blob/trunk/lib/automations.js), makes sure you import your automation configuration into this file and add it to the `moduleNames` array. So for example, if your automation was setup in `lib/automations/my-automation`, you would have something like this in the file after your changes:
74
73
75
-
```js
74
+
- As noted above, this export must include a `runner` for your automation. The runner is an async function that will receive two arguments: `context`(which is the GitHub action context value) and `octokit` (which is the GitHub api helper). See more about these two arguments [here](https://github.com/actions/toolkit/tree/trunk/packages/github) (they are essentially what gets exposed by the `@actions/github` package). You can use the [`todos` runner as an example](https://github.com/woocommerce/automations/blob/trunk/lib/automations/todos/runner.js).
75
+
- Finally, in [`lib/automations.js`](https://github.com/woocommerce/automations/automations/blob/trunk/lib/automations.js), makes sure you import your automation configuration into this file and add it to the `moduleNames` array. So for example, if your automation was setup in `lib/automations/my-automation`, you would have something like this in the file after your changes:
- make sure you list your automation name and a brief description of what it does in the **Available Automations** section of this readme file.
95
+
- make sure you list your automation name and a brief description of what it does in the **Available Automations** section of this readme file.
95
96
96
97
That's it!
97
98
98
99
Don't forget to add tests for your automation. There are various helpers available for mocking the `context` and `octokit` values (you can view the various todos automation tests for examples).
99
100
100
-
101
101
## Credits
102
102
103
-
- Thanks to the work of the [Gutenberg team](https://github.com/wordpress/gutenberg) (particularly [@aduth](https://github.com/aduth)) in providing some inspiration for this approach to bundling various automations together.
104
-
- The `todos` automation was inspired by this [todo probot app](https://github.com/JasonEtco/todo). Initial iterations of this action borrowed heavily from the ideas in this app.
103
+
- Thanks to the work of the [Gutenberg team](https://github.com/wordpress/gutenberg) (particularly [@aduth](https://github.com/aduth)) in providing some inspiration for this approach to bundling various automations together.
104
+
- The `todos` automation was inspired by this [todo probot app](https://github.com/JasonEtco/todo). Initial iterations of this action borrowed heavily from the ideas in this app.
When a pull request is approved and is not already assigned a milestone, this automation will assign the next milestone to it
4
+
automatically.
5
+
6
+
## Usage
7
+
8
+
To implement this action, include it in your workflow configuration file:
9
+
10
+
```yaml
11
+
on:
12
+
pull_request:
13
+
types: [opened, synchronize, closed]
14
+
push:
15
+
issues:
16
+
types: [edited]
17
+
jobs:
18
+
pull-request-automation:
19
+
runs-on: ubuntu-latest
20
+
steps:
21
+
- uses: woocommerce/automations@v1
22
+
with:
23
+
github_token: ${{ secrets.GITHUB_TOKEN }}
24
+
# This can be a comma delimited list of automations to run, in this case we're just executing assign-milestone
25
+
automations: assign-milestone
26
+
```
27
+
28
+
## API
29
+
30
+
### Inputs
31
+
32
+
- `github_token`: Required. GitHub API token to use for making API requests. You can use the default `secrets.GITHUB_TOKEN` used by GitHub actions or store a different one in the secrets configuration of your GitHub repository.
33
+
- `automations`: Optional. You can include a comma-delimited list of specific automations you want to run if you don't want to use them all in a given workflow.
0 commit comments