Skip to content

bitranox/keep_github_workflows_active

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

keep_github_workflows_active

Version v1.1.0 as of 2024-03-01 see Changelog

build_badge codeql license jupyter pypi PyPI - Downloads black codecov Maintainability Maintainability Code Coverage snyk

GitHub Workflow Management Script

This manual guides you through the execution of a Python script designed to manage GitHub workflows across all repositories of a user. The script performs two main functions:

  1. Keep All Workflows Active: Ensures that all workflows in each repository of the user remain in an active state.
  2. Delete Old Workflow Runs: For each repository, this function retains a specified number of the most recent workflow runs and deletes all older runs.

Access Key

In order to access the repository workflows, you will need a fine-grained personal test token. Follow the link to generate the token:

Permissions

Ensure the access key has the following permissions:

  • Action: Read/Write
  • Metadata: Read

Test Token Details

The current test token is valid until 2025-01-19 and needs to be renewed annually.

Token Storage for testing

The token is stored as a secret in the repository's "repository secrets." Navigate to the following link to manage repository secrets:

Secrets Information

The following secrets need to be set:

  • SECRET_GITHUB_OWNER: the GitHub username
  • SECRET_GITHUB_TOKEN: The fine-grained access key

automated tests, Github Actions, Documentation, Badges, etc. are managed with PizzaCutter (cookiecutter on steroids)

Python version required: 3.8.0 or newer

tested on recent linux with python 3.12 - architectures: amd64

100% code coverage, flake8 style checking ,mypy static type checking ,tested under Linux, automatic daily builds and monitoring



Try it Online

You might try it right away in Jupyter Notebook by using the "launch binder" badge, or click here

Usage

  • example for including docstrings
def main() -> None:
    """
    enable all workflows in all repositories for the given owner
    >>> # we actually don't do that here AGAIN because of GitHub Rate limits
    >>> # those functions are called anyway already by doctest
    >>> # main()

    """

Usage from Commandline

Usage: keep_github_workflows_active [OPTIONS] COMMAND [ARGS]...

  keep gitgub workflows active

Options:
  --version                     Show the version and exit.
  --traceback / --no-traceback  return traceback information on cli
  -h, --help                    Show this message and exit.

Commands:
  info  get program informations

Installation and Upgrade

  • Before You start, its highly recommended to update pip:
python -m pip --upgrade pip
  • to install the latest release from PyPi via pip (recommended):
python -m pip install --upgrade keep_github_workflows_active
  • to install the latest release from PyPi via pip, including test dependencies:
python -m pip install --upgrade keep_github_workflows_active[test]
  • to install the latest version from github via pip:
python -m pip install --upgrade git+https://github.com/bitranox/keep_github_workflows_active.git
  • include it into Your requirements.txt:
# Insert following line in Your requirements.txt:
# for the latest Release on pypi:
keep_github_workflows_active

# for the latest development version :
keep_github_workflows_active @ git+https://github.com/bitranox/keep_github_workflows_active.git

# to install and upgrade all modules mentioned in requirements.txt:
python -m pip install --upgrade -r /<path>/requirements.txt
  • to install the latest development version, including test dependencies from source code:
# cd ~
$ git clone https://github.com/bitranox/keep_github_workflows_active.git
$ cd keep_github_workflows_active
python -m pip install -e .[test]
  • via makefile: makefiles are a very convenient way to install. Here we can do much more, like installing virtual environments, clean caches and so on.
# from Your shell's homedirectory:
$ git clone https://github.com/bitranox/keep_github_workflows_active.git
$ cd keep_github_workflows_active

# to run the tests:
$ make test

# to install the package
$ make install

# to clean the package
$ make clean

# uninstall the package
$ make uninstall

Requirements

following modules will be automatically installed :

## Project Requirements
click
cli_exit_tools
lib_detect_testenv
lib_log_utils
toml
requests

Acknowledgements

  • special thanks to "uncle bob" Robert C. Martin, especially for his books on "clean code" and "clean architecture"

Contribute

I would love for you to fork and send me pull request for this project. - please Contribute

License

This software is licensed under the MIT license

---

Changelog

  • new MAJOR version for incompatible API changes,
  • new MINOR version for added functionality in a backwards compatible manner
  • new PATCH version for backwards compatible bug fixes

v1.1.0

2024-02-29:
  • disable windows and osx tests to avoid hitting API limits
  • omit mypy option --no-implicit-reexport
  • github actions/checkout@v4
  • github actions/setup-python@v5
  • use requests instead of urllib
  • delete old Workflow runs

v1.0.0

2024-01-20: initial release