/pyaction

Proof of context for a Python based GitHub action configuration

Primary LanguagePython

pyactions

build standard-readme compliant

A very silly proof of concept

Table of Contents

About

I've read this blog post on Reddit and tried to implement something that could work as a configuration but has all the goods of a programming language. I've used python because I am most proficient in it, but this could be created in any language (maybe not intercal).

This works by simply using python to generate a valid GitHub actions YAML file. ¯\(ツ)

Install

pip install -r requirements.txt

Usage

See this example. It generates an equivalent YAML to the one being used in this repository right now.

from action import Action

class GitHubAction(Action):
    def configure(self):
        self.name = 'build'
        self.on = ['push', 'pull_request']

        with self.job('build') as j:
            j.runs_on = 'ubuntu-latest'
            j.uses('actions/checkout@v2')
            with j.uses('actions/steup-python@v2') as setup:
                setup['python-version'] = '3.9'
            j.run('pip install -r requirements.txt')
            j.run('python -m unittest -vb test.py')

action = GitHubAction()
yaml = action.yaml()