A project base for automating tasks in Python using GitHub actions and an Aiven for PostgreSQL database.
-
Create a new repository using this repository as a template.
-
Create a new Aiven PostgreSQL service.
-
Copy
.env.example
to.env
and fill in the values. -
Install poetry and the dependencies (base + dev) using the following commands:
pip install poetry poetry install --all-extras
-
Initialize the database using the following command:
make migration-init migration-apply
-
Push to GitHub, set the repo secrets and enable GitHub actions.
-
This will start populating your database with Quotes (example pipeline).
- Create an Aiven account (or reuse an existing one) at aiven.io.
- Create a new PostgreSQL service. You can create a free one if you do not already have one.
- Create a new repository using this repository as a template.
- Set up your repo secrets using the values from your Aiven service.
-
Install poetry and the dependencies (base + dev) using the following commands:
pip install poetry poetry install --all-extras
-
Copy
.env.example
to.env
and fill in the values, using the values from your Aiven service.
There are four files that will interest you:
gh_automation_base/pipelines/quotes.py
: the example pipeline file.- Delete this file and create your own pipeline file.
gh_automation_base/cli.py
: the CLI entrypoint.- Register your own endpoint here. You can delete the
quotes
endpoint.
- Register your own endpoint here. You can delete the
migrations/*
: the database migrations.- Declare your tables here. If you do not use the example pipeline, you should delete the
quotes
table migration file before running any migration command.
- Declare your tables here. If you do not use the example pipeline, you should delete the
.github/workflows/run-task.yml
: the GitHub action workflow file.- Modify the
poetry run auto quotes
command to call your own endpoint instead. - Change the cron schedule to your liking.
- Modify the
After having created all the migrations you need (using make migration-new
), you can initialize your database using the following command:
make migration-init migration-apply
- Have GitHub call your endpoint in the workflow file here:
poetry run auto <your-endpoint>
. - Push your code to your repository.