GitHub Action
Need More Info
A GitHub Action that requests more info when required content is not included in an issue. You can check out test runs here.
The Action has two properties that have defaults and are not required.
- config-path: Path to the config file, defaults to
.github/need-info.yml
- repo-token: Token for the repository, defaults to
${{ github.token }}
# .github/workflows/verify-info.yml
name: 'Need Info - Verify'
on:
issues:
types: [labeled]
branches: [master]
issue_comment:
types: [created]
branches: [master]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: benelan/need-info-action@v2
# the rest is not required if using the defaults
with:
github-token: 'super-duper-secret-token-sshhh'
config-path: '.github/configs/not-default.yml'
The following properties can be set in the configuration file.
Config Property | Type | Description |
---|---|---|
requiredItems (required) | InfoItem[] | Items that an issue with a labelToCheck must include, triggers a response if they are missing |
labelsToCheck (required) | string[] | Labels that trigger a check for InfoItem content |
labelToAdd (required) | string | Label added to issues with missing information |
commentHeader | string | Comment message to add above the ItemInfo responses |
commentFooter | string | Comment message to add below the ItemInfo responses |
caseSensitive | boolean | Whether InfoItem content is case sensitive, default: false |
excludeComments | boolean | Exclude content in markdown comments when parsing for InfoItem content, default: false |
exemptUsers | string[] | Users that are exempt from providing InfoItem content |
includedItems | InfoItem[] | Items that trigger a response if they are included and the action found missing requiredItems |
InfoItem Property | Type | Description |
---|---|---|
content (required) | string[] | A list of content to check for in an issue or comment |
response (required) | string | A response to comment on an issue if requirements are not satisfied |
requireAll (required) | boolean | Whether to require all of the content items or just one |
# .github/need-info.yml
labelToAdd: 'need more info'
labelsToCheck:
- 'bug'
- 'enhancement'
requiredItems:
- content:
- '## Actual Behavior'
- '## Expected Behavior'
response: '- Use the appropriate format from the issue templates'
requireAll: true
- content:
- 'jsbin.com'
- 'codepen.io'
- 'jsfiddle.net'
- 'codesandbox.io'
response: '- A sample that reproduces the issue'
requireAll: false
# optional properties below
commentHeader: 'More information is required to proceed:'
commentFooter: 'This issue will be automatically closed in a week if the information is not provided. Thanks for your understanding.'
caseSensitive: true
excludeComments: true # don't parse markdown comments in the issue/comment
exemptUsers:
- benelan
includedItems:
- content:
- 'https://esri.github.io/calcite-components/?path=/story/components-'
- 'https://developers.arcgis.com/calcite-design-system/components/'
response: ' - @benelan will confirm that the issue is reproducible in the documentation. In the meantime, **no action is required** on your end.'
requireAll: false
The appropriate method is determined depending on whether the Action is triggered by an issue or comment event.
The issues
event methods can be run on opened
, edited
, and/or labeled
.
- The
opened
action checks if an issue has at least one of thelabelsToCheck
. Thelabeled
action, checks if the added label is a label to check. If so, it checks the issue body for therequiredItems
.- If the issue satisfies all of the requirements then the Action ends.
- If any requirement is not satisfied then
labelToAdd
is added to the issue. The Action comments on the issue with theresponse
for all of therequiredItems
that were not provided. The Action also comments with the response for theincludedItems
that are in the issue. TheincludedItems
can be used to explain why certain content cannot be accepted in place of required items, among other things.
- The
edited
action checks if an issue has thelabelToAdd
. If it does, it checks the issue body for the required items.- If the edited issue body now contains all of the required items, the
labelToAdd
is removed.
- If the edited issue body now contains all of the required items, the
The issue_comment
event method can be run on created
and/or edited
actions.
- If there is a comment on an issue with the
labelToAdd
then the Action checks the comment for anyrequiredItems
.- If the comment satisfies any ONE required item then the
labelToAdd
is removed from the issue. - If the comment does not have any
requiredItems
then the Action ends.
- If the comment satisfies any ONE required item then the
- If the commented issue does not have the
labelToAdd
, or the commenter is not the original poster, then the Action ends.
Note: If there were multiple
requiredItems
that the commenter needed and they only provided one, the maintainer can manually ask for the additional items and add back thelabelToAdd
.
This Action can be used in conjunction with Close Stale Issues, which can be set up to close issues with the labelToAdd
after a certain amount of time. You can check out a test run here.
# .github/workflows/close-issue.yml
name: 'Need Info - Close'
on:
schedule:
- cron: '30 1 * * *'
jobs:
close:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
days-before-stale: -1 # do not automatically label issues
days-before-close: 7
remove-stale-when-updated: false # do not automatically remove label
stale-issue-label: 'need more info'
stale-pr-label: 'need more info'
close-issue-message: 'This issue has been automatically closed due to missing information. We will reopen the issue if the information is provided.'