def main()

in tools/build_readme.py [0:0]


def main():

    GITHUB_WORKSPACE  = os.getenv('GITHUB_WORKSPACE')
    GITHUB_REPOSITORY = os.getenv('GITHUB_REPOSITORY')
    WORKFLOW_EMAIL    = os.getenv('WORKFLOW_EMAIL')
    WORKFLOW_USERNAME = os.getenv('WORKFLOW_USERNAME')
    WORKFLOW_PAT      = os.getenv('WORKFLOW_PAT')

    # print(GITHUB_WORKSPACE)

    modules_dir = GITHUB_WORKSPACE + '/modules'

    for module in glob.glob(modules_dir + '/*'):

        # print(module)

        try:
            # run the tfdoc.py
            os.system('python3 tfdoc.py ' + module)

        except Exception as e:
            raise SystemExit(e)
    
    try: 
        # commit files
        os.system('git config --local user.email ' + WORKFLOW_EMAIL)
        os.system('git config --local user.name ' + WORKFLOW_USERNAME)
        os.system('git add -A')
        os.system('git commit -m "[WORKFLOW] Auto updating RAD-Lab Modules README.md" -a')

        remote_repo="https://"+WORKFLOW_USERNAME+":"+WORKFLOW_PAT+"@github.com/"+GITHUB_REPOSITORY+".git"

        # push changes
        os.system('git push ' + remote_repo + ' HEAD:main --force')

    except Exception as e:
        raise SystemExit(e)