-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
240e9ca
commit 836829b
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |