Module: GitHubFunctions

github.js

Version:
  • 3.0.0
Author:
License:
  • Apache-2.0
Source:

Example

const gitHubCtl = new GitHubFunctions(accessToken, myOrgName, 'mr-cli-setup')
const createRepoResp = await gitHubCtl.createRepository()

Requires

  • module:octokit

Methods


<inner> catchContainer(repoMetadata)

Catches a container by locking it, creating a new branch, reading the objects

Parameters:
Name Type Description
repoMetadata Object

The metadata object

Source:
Returns:

Status, message, and metadata

Type
Promise.<Array>

<async, inner> checkForLock(containerName)

Checks to see if a container is locked.

Parameters:
Name Type Description
containerName string

The name of the container to check for a lock.

Source:
Returns:

A promise that resolves to an array containing status and message.

Type
Promise.<Array>

<async, inner> createBranchFromMain()

Creates a new branch from the main branch.

Source:
Returns:

A promise that resolves to an array containing a boolean indicating success, a message, and the response.

Type
Promise.<Array>

<inner> createContainers()

Creates the top level Study, Company and Interaction containers for all mediumroast.io assets

Source:
Returns:

An array with position 0 being boolean to signify success/failure and position 1 being the responses or error messages.

Type
Array

<inner> createRepository()

Creates a repository, at the organization level, for keeping track of all mediumroast.io assets

Source:
Returns:

An array with position 0 being boolean to signify success/failure and position 1 being the created repo or error message.

Type
Array

<async, inner> deleteObject(objName, source, repoMetadata, catchIt)

Deletes an object from a specified container

Parameters:
Name Type Description
objName string

The name of the object to delete

source object

The source object that contains the from and to containers

repoMetadata object

The repository metadata

catchIt boolean

Whether to catch the container

Source:
Returns:

Status, message, and response

Type
Promise.<Array>

<async, inner> getActionsBillings()

Gets the complete billing status for actions from the GitHub API

Source:
Returns:

An array with position 0 being boolean to signify success/failure and position 1 being the user info or error message.

Type
Array

<async, inner> getAllUsers()

Gets all of the users from the GitHub API

Source:
Returns:

An array with position 0 being boolean to signify success/failure and position 1 being the user info or error message.

Type
Array

<inner> getGitHubOrg()

If the GitHub organization exists retrieves the detail about it and returns to the caller

Source:
Returns:

An array with position 0 being boolean to signify success/failure and position 1 being the org or error message.

Type
Array

<async, inner> getRepoSize()

Gets the size of the repository in MB

Source:
Returns:

An array with position 0 being boolean to signify success/failure and position 1 being the response or error message.

Type
Array

<async, inner> getStorageBillings()

Gets the complete billing status for actions from the GitHub API

Source:
Returns:

An array with position 0 being boolean to signify success/failure and position 1 being the user info or error message.

Type
Array

<async, inner> getUser()

Gets the authenticated user from the GitHub API

Source:
Returns:

An array with position 0 being boolean to signify success/failure and position 1 being the user info or error message.

Type
Array

<async, inner> getWorkflowRuns()

Gets all of the workflow runs for the repository

Source:
Returns:

An array with position 0 being boolean to signify success/failure and position 1 being the response or error message.

Type
Array

<async, inner> lockContainer(containerName)

Locks a container by creating a lock file in the container.

Parameters:
Name Type Description
containerName string

The name of the container to lock.

Source:
Returns:

A promise that resolves to an array containing status and message.

Type
Promise.<Array>

<async, inner> mergeBranchToMain(branchName, mySha [, commitDescription])

Merges a specified branch into the main branch by creating a pull request.

Parameters:
Name Type Argument Default Description
branchName string

The name of the branch to merge into main.

mySha string

The SHA of the commit to use as the head of the pull request.

commitDescription string <optional>
'Performed CRUD operation on objects.'

The description of the commit.

Source:
Returns:

A promise that resolves to an array containing success status, message, and response.

Type
Promise.<Array>

<async, inner> readObjects(containerName)

Reads objects from a specified container using the GitHub API.

Parameters:
Name Type Description
containerName string

The name of the container to read objects from.

Source:
Returns:

Status, message, and contents

Type
Promise.<Array>

<inner> releaseContainer(repoMetadata)

Releases a container by unlocking it and merging the branch

Parameters:
Name Type Description
repoMetadata Object

The metadata object

Source:
Returns:

Status, message, and response

Type
Promise.<Array>

<async, inner> unlockContainer(containerName, commitSha, branchName)

Unlocks a container by deleting the lock file in the container.

Parameters:
Name Type Description
containerName string

The name of the container to unlock.

commitSha string

The SHA of the commit to use as the head of the pull request.

branchName string

The name of the branch to unlock the container on.

Source:
Returns:

A promise that resolves to an array containing status and message.

Type
Promise.<Array>

<async, inner> updateObject(containerName, objName, key, value [, dontWrite] [, system] [, whiteList])

Updates an object in a specified container

Parameters:
Name Type Argument Default Description
containerName string

The name of the container containing the object

objName string

The name of the object to update

key string

The key of the object to update

value string

The value to update the key with

dontWrite boolean <optional>
false

A flag to indicate if the object should be written back

system boolean <optional>
false

A flag to indicate if the update is a system call

whiteList Array <optional>
[]

A list of keys that are allowed to be updated

Source:
Returns:

Status, message, and response

Type
Promise.<Array>

<async, inner> writeObject(containerName, obj, ref, mySha)

Writes an object to a specified container using the GitHub API.

Parameters:
Name Type Description
containerName string

The name of the container to write the object to.

obj object

The object to write to the container.

ref string

The reference to use when writing the object.

mySha string

The SHA of the current file if updating.

Source:
Returns:

Status, message, and response

Type
Promise.<Array>