Skip to main content

A Flask application to handle postman webhooks for deploying and taking down repositories.

Project description

Airflow Deploy Softwrd

This is a Flask application that handles GitHub webhook POST requests for deploying and taking down repositories using Docker Compose. It is designed for managing Airflow deployments of softwrd in-house hosted repositories.

Features

  • Deploy specified branches of a repository on push events (via /payload).
  • Bring down specified branches of a repository (via /putdown).
  • Retrieve secrets from AWS Secrets Manager for environment and Airflow variables.
  • Automatically configure environment variables from secrets.
  • Supports both HTTPS and SSH cloning (configurable).
  • Runs deployment and takedown logic in background threads for responsiveness.

Prerequisites

  • Python 3.9 or higher
  • Docker and Docker Compose — both the V2 plugin (docker compose) and the standalone V1 binary (docker-compose) are supported; the application auto-detects whichever is available, preferring V2.
  • AWS credentials setup if using Secrets Manager

Installation

You can install the package from PyPI:

pip install airflow_deploy_softwrd

Configuration

AWS Credentials Setup

Set up your AWS credentials using the following command:

$Env:AWS_ACCESS_KEY_ID = "your-access-key-id"
$Env:AWS_SECRET_ACCESS_KEY = "your-secret-access-key"

you must have to set up your AWS credentials in your environment variables before running the application.

Usage

To run the server, use the following command:

airflow_deploy_softwrd /path/to/your/working/directory /path/to/config.json

Command Line Arguments

  • /path/to/your/working/directory: The base directory where repositories will be cloned and operated.
  • /path/to/config.json: Path to the configuration file containing allowed branches.

Configuration File

Create a JSON configuration file, e.g., config.json, with the following contents to specify allowed branches and SSH support: Set "SSH": true if you want to clone repositories using SSH instead of HTTPS.

{
  "allowed_branches": ["develop", "main", "Airflow-Changelog"],
  "SSH": false
}

Required AWS Secrets

Set up the following secrets in AWS Secrets Manager:

  • airflow_deployment_env: Secret containing environment variables for deploying Airflow (as a JSON object).
  • airflow_variables_env: Secret containing Airflow variable configurations (as a JSON object).

POSTMAN Webhooks

Set up your webhook sender (e.g., GitHub or POSTMAN) to point to the following endpoints of your running Flask application:

  • Deploy a branch:

    • http://localhost:6969/payload
  • Bring down a branch:

    • http://localhost:6969/putdown

Example Webhook Payloads

Deploy a Branch

The webhook payloads for both endpoints should include the following fields:

Branch Name Format:

  • You can provide the branch name as either just the branch name (e.g., main) or prefixed with refs/heads/ (e.g., refs/heads/main).
  • Other formats such as refs/<branch_name> or heads/<branch_name> are not supported and will break the application.
{
  "ref": "refs/heads/main",
  "repository": {
    "clone_url": "https://github.com/yourusername/yourrepo.git",
    "name": "yourrepo"
  },
  "head_commit": {
    "message": "Your commit message"
  }
}

Bring Down a Branch

The webhook for bringing down a branch should contain similar information:

{
  "ref": "refs/heads/main",
  "repository": {
    "clone_url": "https://github.com/yourusername/yourrepo.git",
    "name": "yourrepo"
  },
  "head_commit": {
    "message": "Your commit message"
  }
}

Additional Notes

  • The application must be started with two arguments: the base path for repositories and the path to the config file.
  • Only branches listed in allowed_branches in your config file will be processed.
  • If SSH is set to true in the config, repositories will be cloned using SSH URLs.
  • All deployment and takedown operations are run in background threads for non-blocking webhook responses.

Contact

Maintainer: Md Robiuddin

Project Link: Repository URL

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

airflow_deploy_softwrd-0.0.10.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

airflow_deploy_softwrd-0.0.10-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file airflow_deploy_softwrd-0.0.10.tar.gz.

File metadata

  • Download URL: airflow_deploy_softwrd-0.0.10.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for airflow_deploy_softwrd-0.0.10.tar.gz
Algorithm Hash digest
SHA256 52c31734813ba3edd110edacadc874223e89611d252eeed5957b0f2be1a8d666
MD5 ba6ce3a6e2572effcf098ac7a2462384
BLAKE2b-256 8fd25c5d8e699896bb33eed4bc00d5bddc589cbdf962777093fa7d41821fff8f

See more details on using hashes here.

File details

Details for the file airflow_deploy_softwrd-0.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for airflow_deploy_softwrd-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 09cc1810721c89ea6baeb698b223f79f620dd9fff8720e320460e0e327502c9a
MD5 db67f7164dfdcbd7a30585b5f00eed7d
BLAKE2b-256 6c17fafa82d5fd9ed6d817c43b9f549784028159c650296edca2e62d8edbcdda

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page