Skip to content

Commit

Permalink
email not yet set up
Browse files Browse the repository at this point in the history
  • Loading branch information
bloombar committed Nov 26, 2024
0 parents commit fe7ad22
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/hook.yml
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);
});
"
18 changes: 18 additions & 0 deletions README.md
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.

0 comments on commit fe7ad22

Please sign in to comment.