Skip to content

Commit 47e7b58

Browse files
committed
feat: add option for single milestone with no due date
1 parent e5effd6 commit 47e7b58

File tree

4 files changed

+52
-12
lines changed

4 files changed

+52
-12
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,21 @@ jobs:
2424
steps:
2525
- uses: benelan/milestone-action@v3
2626
with:
27-
farthest: true # remove this line to add the current milestone
28-
overwrite: true # remove this line to keep an existing milestone
27+
farthest: false # if true, add the milestone with the farthest due date.
28+
overwrite: true # if true, allow overwriting an existing milestone.
29+
single: false # if true, add a milestone if it's the only one open,
30+
# even if it doesn't have a due date.
2931
```
3032

3133
## Changelog
3234

35+
### [3.1.0](https://github.com/benelan/milestone-action/compare/v3.0.0...v3.1.0) (2024-02-10)
36+
37+
#### Features
38+
39+
- Add `single` option for workflows the consist of a single open milestone with
40+
no due date.
41+
3342
### [3.0.0](https://github.com/benelan/milestone-action/compare/v2.0.0...v3.0.0) (2024-01-24)
3443

3544
#### Breaking Changes

action.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
name: 'Add Milestone By Due Date'
2-
description: 'Add the milestone with the current or farthest due date to pull requests and issues'
3-
author: 'Ben Elan'
1+
name: "Add Milestone By Due Date"
2+
description: "Add the milestone with the current or farthest due date to pull requests and issues"
3+
author: "Ben Elan"
44
branding:
55
icon: calendar
66
color: green
77
inputs:
88
repo-token:
9-
description: 'Token for the repository. Defaults to `{{ github.token }}`'
9+
description: "Token for the repository. Defaults to `{{ github.token }}`"
1010
default: ${{ github.token }}
1111
required: false
1212
farthest:
13-
description: 'Set this boolean to `true` if you want to add the milestone with the farthest due date. Defaults to `false`, which adds the current milestone.'
13+
description: "Set this boolean to `true` if you want to add the milestone with the farthest due date. Defaults to `false`, which adds the current milestone."
1414
required: false
15-
default: 'false'
15+
default: "false"
1616
overwrite:
17-
description: 'Set this boolean to `true` if you want the action to overwrite existing milestones on issues. Defaults to `false`, which ends the run if the issue already has a milestone.'
17+
description: "Set this boolean to `true` if you want the action to overwrite existing milestones on issues. Defaults to `false`, which ends the run if the issue already has a milestone."
1818
required: false
19-
default: 'false'
19+
default: "false"
20+
single:
21+
description: "Set this boolean to `true` if you only have a single milestone open at a time but don't set the due date. Defaults to `false`, which will not select a milestone if it doesn't have a due date, even if there is only one milestone open."
22+
required: false
23+
default: "false"
2024
runs:
21-
using: 'node20'
22-
main: 'dist/index.js'
25+
using: "node20"
26+
main: "dist/index.js"

dist/index.js

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export async function run(): Promise<void> {
2424

2525
const farthest = getBooleanInput("farthest");
2626
const overwrite = getBooleanInput("overwrite");
27+
const single = getBooleanInput("single");
2728

2829
const token = getInput("repo-token");
2930
const octokit = getOctokit(token);
@@ -48,6 +49,21 @@ export async function run(): Promise<void> {
4849
process.exit(0);
4950
}
5051

52+
if (single && milestones.length === 1) {
53+
await octokit.rest.issues.update({
54+
...repo,
55+
issue_number,
56+
milestone: milestones[0].number,
57+
});
58+
59+
notice(
60+
`Success: the issue or pull request was added to the "${milestones[0]?.title}" milestone.`,
61+
);
62+
63+
setOutput("milestone", milestones[0]);
64+
process.exit(0);
65+
}
66+
5167
const currentDate = new Date(Date.now());
5268
currentDate.setUTCHours(0, 0, 0, 0);
5369

0 commit comments

Comments
 (0)