-
Notifications
You must be signed in to change notification settings - Fork 42
46 lines (37 loc) · 1.48 KB
/
congrats.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
41
42
43
44
45
46
name: Congratulatory Message
on:
issues:
types: [opened]
push:
branches: [main] # Change this to your default branch
pull_request:
types: [opened, closed]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Send Congratulatory Message
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
run: |
echo "Congratulations @${{ github.event.pull_request.user.login }}! Your PR has been merged! 🎉"
# Optionally, you can call the OpenAI API to generate a unique message.
# Install curl if it's not available
sudo apt-get install curl
# Set your OpenAI API Key in the repository secrets
OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
# Call OpenAI API
RESPONSE=$(curl https://api.openai.com/v1/chat/completions \
-s \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Generate a unique congratulatory message for a GitHub contributor."}],
"max_tokens": 50
}')
# Extract the content from the response
MESSAGE=$(echo $RESPONSE | jq -r '.choices[0].message.content')
# Print the message
echo "Message from OpenAI: $MESSAGE"