forked from actions/runner-images
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added workflow step to check for spammy issue (actions#3370)
- Loading branch information
1 parent
0871444
commit 68aa36b
Showing
1 changed file
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,42 @@ jobs: | |
repo-token: "${{ secrets.GITHUB_TOKEN }}" | ||
configuration-path: "./triage-rules.yml" | ||
|
||
- if: always() | ||
uses: actions/[email protected] | ||
- uses: actions/github-script@v4 | ||
id: check-if-spammy | ||
name: Check if new issue is spammy | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
result-encoding: string | ||
script: | | ||
const issue = context.payload.issue; | ||
const minTitleLength = 2; | ||
const titleLength = issue.title.trim().split(' ').length; | ||
const isEmptyToolRequest = !!(issue.title.includes('[tool name]') && issue.body.includes('Tool name: <!--- Name -->')); | ||
if (isEmptyToolRequest || titleLength < minTitleLength) { | ||
await github.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issue.number, | ||
body: "This issue appears to have been opened accidentally. I'm going to close it now, but feel free to open a new issue or ask any questions in discussions!" | ||
}); | ||
await github.issues.update({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: ['Invalid'], | ||
issue_number: issue.number, | ||
state: 'closed' | ||
}); | ||
return true; | ||
} | ||
return false; | ||
- if: ${{ steps.check-if-spammy.outputs.result == 'false' }} | ||
uses: actions/github-script@v4 | ||
name: Assign labels to issue | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
|