-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
11 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 |
---|---|---|
@@ -1,23 +1,37 @@ | ||
name: 'Hello Comment Response' | ||
name: 'Hello Response Workflow' | ||
|
||
on: | ||
issues: | ||
types: [opened] | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
commentReply: | ||
respond-to-hello: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check for specific comment | ||
- name: Check for "hello" in issue description or comment | ||
uses: actions/github-script@v5 | ||
with: | ||
script: | | ||
const issueComment = context.payload.comment.body | ||
if (issueComment === 'hello') { | ||
github.rest.issues.createComment({ | ||
issue_number: context.payload.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'hola!' | ||
}) | ||
const issueContext = context.issue; | ||
const repositoryContext = context.repo; | ||
let issueBody = ''; | ||
// Check if the trigger was an issue or comment event | ||
if (context.eventName === 'issues') { | ||
issueBody = context.payload.issue.body; | ||
} else if (context.eventName === 'issue_comment') { | ||
issueBody = context.payload.comment.body; | ||
} | ||
// Check if the content contains "hello" | ||
if (issueBody.includes('hello')) { | ||
// Add a comment to the current issue | ||
await github.rest.issues.createComment({ | ||
owner: repositoryContext.owner, | ||
repo: repositoryContext.repo, | ||
issue_number: issueContext.number, | ||
body: 'hola!', | ||
}); | ||
} |