gitapi#

showyourwork.gitapi.create_repo(name, description=None, private=False, org=None)#

Create a new repository on GitHub.

Parameters
  • name (str) – The name of the repository (without the user).

  • private (bool, optional) – Set to True for private repos. Default False.

  • org (str, optional) – Name of the organization (if applicable). Default is None.

showyourwork.gitapi.delete_repo(name, org=None, quiet=False)#

Delete a repository on GitHub.

Parameters
  • name (str) – The name of the repository (without the user).

  • org (str, optional) – Name of the organization (if applicable). Default is None.

  • quiet (bool, optional) – Default False.

showyourwork.gitapi.get_access_token(token_name='GH_API_KEY', error_if_missing=False)#

Return the access token stored in the environment variable token_name.

Parameters
  • token_name (str, optional) – Name of the environment variable containing the GitHub API token. Default is GH_API_KEY.

  • error_if_missing (bool, optional) – Raise an error if the environment variable is not defined or empty? Default False.

showyourwork.gitapi.get_authenticated_user()#

Return the name of the current authenticated GitHub user.

showyourwork.gitapi.get_latest_workflow_run_status(name, org=None)#

Checks the status of the latest GH Actions workflow run for a repository.

Parameters
  • name (str) – The name of the repository (without the user).

  • org (str, optional) – The name of the organization (if applicable). Default is None.

Returns

A tuple containing (status, conclusion, url).

Return type

tuple

The status is one of

  • queued

  • in_progress

  • completed

The conclusion is one of

  • action_required

  • cancelled

  • failure

  • neutral

  • success

  • skipped

  • stale

  • timed_out

If the workflow is not found, both are set to unknown.

The url is that of the workflow on GitHub actions.