-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit fe7ad22
Showing
2 changed files
with
83 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,65 @@ | ||
name: Notify on Commit or PR Merge | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
notify: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "14" | ||
|
||
- name: Install dependencies | ||
run: npm install -g nodemailer | ||
|
||
- name: Determine event type | ||
id: event_type | ||
run: echo "::set-output name=event_type::${{ github.event_name }}" | ||
|
||
- name: Send email notification | ||
env: | ||
GITHUB_EVENT: ${{ toJson(github.event) }} | ||
GITHUB_ACTOR: ${{ github.actor }} | ||
GITHUB_USER: ${{ github.event.pusher.name || github.event.pull_request.user.login }} | ||
EVENT_TYPE: ${{ steps.event_type.outputs.event_type }} | ||
EMAIL: ${{ secrets.EMAIL }} | ||
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} | ||
run: | | ||
node -e " | ||
const nodemailer = require('nodemailer'); | ||
const transporter = nodemailer.createTransport({ | ||
service: 'gmail', | ||
auth: { | ||
user: process.env.EMAIL, | ||
pass: process.env.EMAIL_PASSWORD | ||
} | ||
}); | ||
const mailOptions = { | ||
from: process.env.EMAIL, | ||
to: process.env.EMAIL, | ||
subject: 'GitHub Event Notification', | ||
text: \`Event Type: ${{ steps.event_type.outputs.event_type }}\n | ||
GitHub Event: ${{ env.GITHUB_EVENT }}\n | ||
GitHub Actor: ${{ env.GITHUB_ACTOR }}\n | ||
GitHub User: ${{ env.GITHUB_USER }}\` | ||
}; | ||
transporter.sendMail(mailOptions, (error, info) => { | ||
if (error) { | ||
return console.log(error); | ||
} | ||
console.log('Email sent: ' + info.response); | ||
}); | ||
" |
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,18 @@ | ||
# Check Git/GitHub Config | ||
|
||
This respository is intended to be used to check a contributor's `git`/GitHub username configuration to ensure that they match. Matching usernames are necessary for ensuring a given contributor's work is tracked correctly. | ||
|
||
## Intended use | ||
|
||
This repository is intended to be used with the **feature branch workflow**: | ||
|
||
1. Clone this repository. | ||
1. Create a new branch. | ||
1. Make a few commits to the branch... the changes made in each commit are not important. | ||
1. Push the new branch to GitHub. | ||
1. Open and approve a pull request so that your feature branch is merged into the `main`/`master` branch. | ||
|
||
You will receive an automated email showing the usernames detected for the commits as well as the pull requests. Ensure that these usernames match. If they do not, fix the problem and try again. | ||
|
||
- commit usernames come from the `git` configuration. | ||
- pull request usernames come from your GitHub account and profile settings. |