This Python script obtains a list of the last week's open, closed, and in-draft PRs made in a GitHub repository. After using the GitHub API to retrieve the pull request data, it sends an email with the summary to a given email address.
- Python 3.x
- Requests library
- Jinja2 library
- python-dotenv library
- secure-smtplib library
-
Clone or download this repository.
git clone git@github.com:hardik-aws/github-pr-summery.git
-
Install the required Python libraries by running the following command:
pip3 install -r requirements.txt
-
Copy .
env.samplefile as a.envfile -
Set up the GitHub API access token:
-- Generate a personal access token from your GitHub account settings.
-- set token value in.envfile asGITHUB_TOKEN -
Configure the email settings:
-- Set the SMTP server and port of your email provider in the.envfile asSMTP_SERVERandSMTP_PORT
-- UpdateEMAIL_ADDRESSandEMAIL_PASSWORDin the.envfile for authentication.
-- Specify the recipient's email address as theUSER_EMAILin the.envfile. -
Set the target GitHub repository:
-- SpecifyGITHUB_USERNAMEandGITHUB_REPONAMEwith the owner's username and repository name in the.envfile
-
Run the Python script using the following command:
python index.py
This Python script obtains a list of the last week's open, closed, and in-draft PRs from the GitHub repository. After using the GitHub API to retrieve the pull request data, it sends an email with the summary to a given email address.
-
Email Template: The email content is generated using an HTML template (
template.html). You can customize the template according to your preference by modifying the HTML structure and styling. -
Email Subject: The subject of the email is defined in the script. Modify the
Subjectfield in themessagevariable to change the subject line.