This project automates the process of creating a newsletter for the Python Community News. It uses the buttondown API to create a newsletter and schedule it.
This project adheres to the standards highlighted in the organization repo. You should be able to find the code of conduct, contributing guidelines, and other community standards in the GitHub Interface or the organization repo.
1. Get a buttondown account and api key.
Visit the buttondown website and create an account. Once you have an account. Setup your newsletter.
There is a create template button on the top right of this repo. Click it and follow the instructions to create a template of this repo in your own account.
Clone the template to your local machine or cloud environment.
python -m venv venv
source venv/bin/activate
python -m pip install -r requirements.txt
You'll need some information to pass to the script. Most of the information can be passed as environment variables or manually.
You will need the following information:
BUTTONDOWN_API_KEY
- Your buttondown api key. You can find this in your buttondown account settings.GITHUB_ACCOUNT
- Your github account name. This is the name of the account that owns the repo you want to pull issues from.GITHUB_REPO
- The name of the repo you want to pull issues from.
GITHUB_API_TOKEN
- Your github api token. You can create one in your GitHub account settings in the Developer Settings section. If you have one, you can use it to increase the rate limit of the GitHub API. You can read more about the GitHub API rate limit here.
export BUTTONDOWN_API_KEY=<your_api_key>
export GITHUB_ACCOUNT=<your_github_account>
export GITHUB_REPO=<your_github_repo>
export GITHUB_API_TOKEN=<your_github_api_token>
python publish_newsletter.py 1 # replace 1 with the issue number you want to publish
Alternatively, if you don't wish to store your values in the environment you can pass the values directly into publish_newsletter.py
.
python publish_newsletter.py 1 \
--buttondown_api_key=<your_api_key> \
--github_account=<your_github_account> \
--github_repo=<your_github_repo> \
--github_api=<your_github_api_token>
You can also call the script with the --help
flag to see all the options.
python publish_newsletter.py --help