Git Product home page Git Product logo

gh-automation-base's Introduction

gh-automation-base

GH_Automation_:: version

License MIT Python 3.11 Poetry Checked with mypy Code style: black Linting: Ruff

A project base for automating tasks in Python using GitHub actions and an Aiven for PostgreSQL database.

Setup (quick start)

  1. Create a new repository using this repository as a template.

  2. Create a new Aiven PostgreSQL service.

  3. Copy .env.example to .env and fill in the values.

  4. Install poetry and the dependencies (base + dev) using the following commands:

    pip install poetry
    poetry install --all-extras
  5. Initialize the database using the following command:

    make migration-init migration-apply
  6. Push to GitHub, set the repo secrets and enable GitHub actions.

  7. This will start populating your database with Quotes (example pipeline).

Make it your own

Create your Aiven service

  1. Create an Aiven account (or reuse an existing one) at aiven.io.
  2. Create a new PostgreSQL service. You can create a free one if you do not already have one.

Create your repository

  1. Create a new repository using this repository as a template.
  2. Set up your repo secrets using the values from your Aiven service.

Set up your local environment

  1. Install poetry and the dependencies (base + dev) using the following commands:

    pip install poetry
    poetry install --all-extras
  2. Copy .env.example to .env and fill in the values, using the values from your Aiven service.

Adapt the code to your needs

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.
  • 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.
  • .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.

Initialize your database

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

Set up the GitHub Action

  1. Have GitHub call your endpoint in the workflow file here: poetry run auto <your-endpoint>.
  2. Push your code to your repository.

gh-automation-base's People

Contributors

mulugruntz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.