Skip to content

Commit

Permalink
Feat/393 post comment when issue is closed as not planned (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
davideroffo authored Jan 31, 2023
1 parent 277ec22 commit 158f9ae
Show file tree
Hide file tree
Showing 9 changed files with 424 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/notify-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
- main
release:
types: [published]
issues:
types: [closed]
schedule:
- cron: '30 8 * * *'
jobs:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
workflow_dispatch:
release:
types: [published]
issues:
types: [closed]
schedule:
- cron: '30 8 * * *'
jobs:
Expand Down
169 changes: 153 additions & 16 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

const ISSUE_LABEL = 'notify-release'
const ISSUE_TITLE = 'Release pending!'
const STATE_OPEN = 'open'
const STATE_CLOSED = 'closed'
const STATE_CLOSED_NOT_PLANNED = 'not_planned'
const ISSUES_EVENT_NAME = 'issues'

module.exports = {
ISSUE_LABEL,
ISSUE_TITLE,
STATE_OPEN,
STATE_CLOSED,
STATE_CLOSED_NOT_PLANNED,
ISSUES_EVENT_NAME,
}
23 changes: 22 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
'use strict'
const core = require('@actions/core')
const toolkit = require('actions-toolkit')
const { context } = require('@actions/github')
const { parseNotifyAfter } = require('./time-utils.js')
const { runAction } = require('./release-notify-action')
const {
getIsSnoozingIssue,
getIsClosingIssue,
addSnoozingComment,
} = require('./issue.js')
const { logInfo } = require('./log.js')

async function run() {
toolkit.logActionRefWarning()
Expand All @@ -15,8 +22,22 @@ async function run() {
core.getInput('stale-days')
)

const commitMessageLines = Number(core.getInput('commit-messages-lines'))
const isSnoozing = getIsSnoozingIssue(context)

if (isSnoozing) {
logInfo('Snoozing issue ...')
const { number } = context.issue
return addSnoozingComment(token, notifyAfter, number)
}

const isClosing = getIsClosingIssue(context)
if (isClosing) {
logInfo('Closing issue. Nothing to do ...')
return
}

logInfo('Workflow dispatched or release published ...')
const commitMessageLines = Number(core.getInput('commit-messages-lines'))
await runAction(token, notifyAfter, commitMessageLines)
}

Expand Down
Loading

0 comments on commit 158f9ae

Please sign in to comment.