-
Notifications
You must be signed in to change notification settings - Fork 1
37 lines (33 loc) · 1.17 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: 'Hello Response Workflow'
on:
issues:
types: [opened]
issue_comment:
types: [created]
jobs:
respond-to-hello:
runs-on: ubuntu-latest
steps:
- name: Check for "hello" in issue description or comment
uses: actions/github-script@v5
with:
script: |
const issueContext = context.issue;
const repositoryContext = context.repo;
let issueBody = '';
// Check if the trigger was an issue or comment event
if (context.eventName === 'issues' && context.payload.issue) {
issueBody = context.payload.issue.body;
} else if (context.eventName === 'issue_comment' && context.payload.comment) {
issueBody = context.payload.comment.body;
}
// Ensure issueBody is not undefined or null before proceeding
if (issueBody && 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!',
});
}