Cleanup based on user feedback #22
Workflow file for this run
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
name: Notify Teams | |
on: | |
pull_request_target: | |
branches: [main] | |
types: [opened, reopened, assigned, closed] | |
env: | |
SMTP_SERVER: smtp.gmail.com | |
SMTP_PORT: 465 | |
EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }} | |
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} | |
EMAIL_FROM: GitHub Actions | |
EMAIL_TO: ${{ secrets.DESTINATION_EMAIL }} | |
# Optional priority: 'high', 'normal' (default) or 'low' | |
jobs: | |
send_email_on_opened_pr: | |
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && (github.event.action == 'opened' || github.event.action == 'reopened') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get PR Data | |
run: | | |
echo "action=${{ github.event.action }}" >> $GITHUB_ENV | |
echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_ENV | |
echo "user=${{ github.event.pull_request.user.login }}" >> $GITHUB_ENV | |
echo "title=${{ github.event.pull_request.title }}" >> $GITHUB_ENV | |
echo "url=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV | |
echo "assignees=${{ join(github.event.pull_request.assignees.*.login, ',') }}" >> $GITHUB_ENV | |
- name: Send Email on Opened PR | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: ${{ env.SMTP_SERVER }} | |
server_port: ${{ env.SMTP_PORT }} | |
username: ${{ env.EMAIL_USERNAME }} | |
password: ${{ env.EMAIL_PASSWORD }} | |
to: ${{ env.EMAIL_TO }} | |
from: ${{ env.EMAIL_FROM }} | |
subject: "***Notification*** Opened Pull Request: ${{ env.number }}" | |
body: | | |
{ | |
"action": "${{ env.action }}", | |
"number": "${{ env.number }}", | |
"user": "${{ env.user }}", | |
"title": "${{ env.title }}", | |
"url": "${{ env.url }}", | |
"assignees": "${{ env.assignees }}" | |
} | |
ignore_cert: true | |
nodemailerlog: true | |
nodemailerdebug: true | |
send_email_on_updated_assignees: | |
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.action == 'assigned' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get Updated Assignees | |
run: | | |
echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_ENV | |
echo "assignees=${{ join(github.event.pull_request.assignees.*.login, ',') }}" >> $GITHUB_ENV | |
echo "title=${{ github.event.pull_request.title }}" >> $GITHUB_ENV | |
- name: Send Email on Updated Assignees | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: ${{ env.SMTP_SERVER }} | |
server_port: ${{ env.SMTP_PORT }} | |
username: ${{ env.EMAIL_USERNAME }} | |
password: ${{ env.EMAIL_PASSWORD }} | |
to: ${{ env.EMAIL_TO }} | |
from: ${{ env.EMAIL_FROM }} | |
subject: "***Notification*** Updated Assignees for Pull Request: ${{ env.number }}" | |
body: | | |
{ | |
"number": "${{ env.number }}", | |
"assignees": "${{ env.assignees }}", | |
"title": "${{ env.title }}" | |
} | |
ignore_cert: true | |
nodemailerlog: true | |
nodemailerdebug: true | |
send_email_on_closed_pr: | |
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && github.event.action == 'closed' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get PR Data | |
run: | | |
echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_ENV | |
echo "title=${{ github.event.pull_request.title }}" >> $GITHUB_ENV | |
- name: Send Email on Closed PR | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: ${{ env.SMTP_SERVER }} | |
server_port: ${{ env.SMTP_PORT }} | |
username: ${{ env.EMAIL_USERNAME }} | |
password: ${{ env.EMAIL_PASSWORD }} | |
to: ${{ env.EMAIL_TO }} | |
from: ${{ env.EMAIL_FROM }} | |
subject: "***Notification*** Closed Pull Request: ${{ env.number }}" | |
body: | | |
{ | |
"number": "${{ env.number }}", | |
"title": "${{ env.title }}" | |
} | |
ignore_cert: true | |
nodemailerlog: true | |
nodemailerdebug: true | |