Skip to content

Commit

Permalink
Add Congratulatory Message workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
danishzayan committed Sep 28, 2024
1 parent 240e9ca commit 836829b
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/congrats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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"

0 comments on commit 836829b

Please sign in to comment.