-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (34 loc) · 1.16 KB
/
greetings.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
38
39
40
name: Greetings
on:
pull_request:
types: [opened]
issues:
types: [opened]
permissions:
issues: write
pull-requests: write
jobs:
greet:
runs-on: ubuntu-latest
steps:
- name: Greet on PRs and Issues
uses: actions/github-script@v7
with:
script: |
try {
const isPR = context.payload.pull_request !== undefined;
const number = isPR ? context.payload.pull_request.number : context.payload.issue.number;
const commentBody = isPR
? `Welcome, @${{ github.actor }}! Thanks for raising the issue!`
: `Great job, @${{ github.actor }}! Thanks for creating the pull request`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: number,
body: commentBody
});
console.log('Comment successfully created.');
} catch (error) {
console.error('Error creating comment:', error);
// Do not mark the step as failed; continue with the workflow.
}