Skip to content

Commit

Permalink
schedule: specify meeting that is multiple days away
Browse files Browse the repository at this point in the history
Currently, the only dates permitted by this action are 'today' and 'tomorrow'.
This prevents scenarios in which, for example, someone would like to create the
issue on Monday and record ideas/topics throughout the week for a meeting on
Friday.

Therefore, this change introduces the concept of 'x days from now'. In addition
to today and tomorrow, users can now specify, for example, 4 days from now for
the scenario described above.
  • Loading branch information
ldennington committed Apr 2, 2024
1 parent 96420d0 commit 4d49858
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inputs:
default: '.github/101.yml'
required: true
scheduled-day:
description: 'Is the meeting today or tomorrow?'
description: 'When is the meeting?'
default: 'today'
required: false

Expand Down
8 changes: 4 additions & 4 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions lib/meeting.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {context, getOctokit} from '@actions/github'
import dayjs from 'dayjs'
import {load} from 'js-yaml'

const scheduleRegex = new RegExp('^[0-9]+ days from now$')

class Meeting {
/**
* @param {object} options
Expand All @@ -24,10 +26,10 @@ class Meeting {
}
this.path = path

if ((schedule !== 'today' && schedule !== 'tomorrow') || !schedule) {
if ((schedule !== 'today' && schedule !== 'tomorrow' && !scheduleRegex.test(schedule)) || !schedule) {
this.log(
'[WARN]',
`scheduled-day was set to '${schedule}'. Only 'today' or 'tomorrow' are allowed. Normalizing to 'today'.`,
`scheduled-day was set to '${schedule}'. Only 'today', 'tomorrow', or 'x days from now' are allowed. Normalizing to 'today'.`,
)
this.schedule = 'today'
} else {
Expand Down Expand Up @@ -194,6 +196,9 @@ class Meeting {

if (schedule === 'tomorrow') {
date = dayjs().add(1, 'days')
} else if (scheduleRegex.test(schedule)) {
const days = parseInt(schedule.split(' ')[0])
date = dayjs().add(days, 'days')
}

const title =
Expand Down
10 changes: 8 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,14 @@ Defaults to `.github/101.yml`.
configuration-path: .github/101.yml
```

Is the meeting today or tomorrow?
Defaults to `today` and will fall back to `today` if neither `today` or `tomorrow` are provided.
When is the meeting?
Acceptable values:

- `today`
- `tomorrow`
- `x days from now` (where x is the number of days away the meeting is)

Defaults to `today` and will fall back to `today` if none of the above are provided.

```yaml
scheduled-day: today
Expand Down

0 comments on commit 4d49858

Please sign in to comment.