Skip to main content

GitHub Environment Housekeeper

Project description

envkeeper

What is Envkeeper?

Envkeeper, coming from "Environment Housekeeper", is a custom composite GitHub Actions to manage GitHub Deployments and its Environment associated.
Thanks to this great features of GitHub, we can realize Continuous Delivery by GitHub Actions, and you can use GitHub Envionments for the applications integrated its repo.

As many of application platforms (PaaS) have PR environments, where it can automatically create GitHub Environment/Deployments and associated acutal deploys on the platforms with linking to Pull Requests, but several services will NOT clean up after the PRs will be merged.
So you might see many of staled environements/deployments have been associated to your repository, and for resolving these kind of caveats we need to have any solutions to purge staled objects in GitHub (StackOverflow's ref).

With using envkp CLI, which will be available with Envkeeper, you can completely purge these staled deployments and linked environments.

envkeeper-actions

As you can use Envkeeper with several forms of implementations according to your requirements, one of the best way is to use as GitHub Actions.
Since we developed Custom Composit GitHub Actions to run Envkeeper (envkp) for housekeeping GitHub Environment, it can be available in GitHub Marketplace.

Usage

Create workflows (ex. .github/workflows/envkeeper.yaml) for using GitHub Actions of envkeeper with contexts:

name: Purge staled environment
on:
  schedule:
    # Runs on 19:00 JST every day, note that cron syntax applied as UTC
    - cron: '0 10 * * *'
  workflow_dispatch:

jobs:
  cleanup-env:
    runs-on: ubuntu-24.04

    permissions:
      deployments: write

    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          ref: ${{ github.head_ref }}

      - name: Clean up Environments
        uses: hwakabh/envkeeper@main
        with:
          token: ${{ github.token }}
          repo: ${{ github.repository }}

Inputs

Inputs have been defined in action.yml:

Name Required Description
token true Token to use to authorize. Typically the GITHUB_TOKEN secrets.
repo true Target repository to check issue title.

Note that GitHub Actions of envkeeper will delete Deployments in the repository, the token has the scope for repo_deployment.

Outputs

TBU, under development.

Name Required Description
result false The results of operations

envkp CLI

As well as envkeeper-actions, you can also use envkp on your local environment as client tools.
Since envkp has been developed purely as Python package, it can be available in PyPI repository.

CLI Install

As mentioned, envkp can be installed from PyPI, so you can easily install it with your favorite Python package manager (such as pip, poetry, uv, ...etc).
Please follow its documents for installation of the package manager first, and be sure that enable venv if you need to have isolated environments.

# pip
% pip install envkp

# poetry
% poetry add envkp

# uv
% uv add envkp

With pip case you can also download it directly from GitHub looked like below, or of course you can download each formats of Python packages files (.tar.gz or .whl formats) from here, and install directly from each file according to your requirements.

# Git
% pip install git+https://github.com/hwakabh/envkeeper.git

Though it has been deprecated way, where we will use setuptools (setup.py) for package installations, you can use one of the options using it if you have already had setuptools in your environments:

% python setup.py install

Usage

envkp has two main subcommands: clean and seek, and both of them will expect repository name as its arguments.
Please note that the value for --repo should be formed as owner/reponame, for example hwakabh/envkeeper.

% envkp --repo ${reponame} clean
% envkp --repo ${reponame} seek

envkp clean will

  • delete all deployments of repo whose status is inactive. This means active deployments, where upstream/latest application code basis are deployed, will NOT be deleted for secure operations.
  • delete all environments of repo, where no deployment has been associated to any deployments

envkp seek will

  • print information of deployments/environments in the repository

Environmental Variables

Name Required Description
GH_TOKEN true Token to use to authorize. Typically the GITHUB_TOKEN secrets.
GH_REPONAME false equivalent with the input for --repo

Good to know / Caveats

Similar solutions it can be available on GitHub:

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

envkp-0.5.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

envkp-0.5.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file envkp-0.5.0.tar.gz.

File metadata

  • Download URL: envkp-0.5.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for envkp-0.5.0.tar.gz
Algorithm Hash digest
SHA256 49410866b4e993494e822d259dd815d5d7ff86132b9d5ea9937551544602b8cb
MD5 3ebd32e32e5ee2bfa70c83004225d36b
BLAKE2b-256 813ed51b47e4952d22a7a069750980b1b6d10677a9cb9eb8c62b66627d6053f3

See more details on using hashes here.

File details

Details for the file envkp-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: envkp-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for envkp-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b61719ec84a2bae32e6f1f92019fe74aba0dd5c70377aee54b258397efe9fa2
MD5 794344c351f4b8dbcbed9c9c53e34802
BLAKE2b-256 e8d816b6507dad6a8f612390f1053ae279f329b5a2c6abadc64d527436fea955

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