Skip to content

Workflow file for this run

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!🤝',
});
}