- GitHubAuth
authorize.js
- GitHubFunctions
github.js
- api/gitHubServer.js
gitHubServer.js
authorize.js
Requires: module:open, module:octoDevAuth, module:chalk, module:cli-table3
Version: 3.0.0
Author: Michael Hay michael.hay@mediumroast.io
License: Apache-2.0
Copyright: 2025 Mediumroast, Inc. All rights reserved.
Example
import {GitHubAuth} from './api/authorize.js'
const github = new GitHubAuth(env, environ, configFile)
const githubToken = github.verifyAccessToken()- GitHubAuth
- ~GitHubAuth
- new GitHubAuth(env, environ, configFile, configExists)
- .verifyGitHubSection() ⇒
Boolean - .getAccessTokenFromConfig() ⇒
String|null - .getAuthTypeFromConfig() ⇒
String|null - .checkTokenExpiration(token) ⇒
Array - .getAccessTokenDeviceFlow() ⇒
Object - .verifyAccessToken(saveToConfig) ⇒
Array
- ~GitHubAuth
Kind: inner class of GitHubAuth
- ~GitHubAuth
- new GitHubAuth(env, environ, configFile, configExists)
- .verifyGitHubSection() ⇒
Boolean - .getAccessTokenFromConfig() ⇒
String|null - .getAuthTypeFromConfig() ⇒
String|null - .checkTokenExpiration(token) ⇒
Array - .getAccessTokenDeviceFlow() ⇒
Object - .verifyAccessToken(saveToConfig) ⇒
Array
| Param | Type | Description |
|---|---|---|
| env | Object |
The environment object |
| environ | Object |
The environmentals object |
| configFile | String |
The configuration file path |
| configExists | Boolean |
Whether the configuration file exists |
Verifies if the GitHub section exists in the configuration
Kind: instance method of GitHubAuth
Returns: Boolean - True if the GitHub section exists, otherwise false
Gets the access token from the configuration file
Kind: instance method of GitHubAuth
Returns: String | null - The access token or null if not found
Gets the authentication type from the configuration file
Kind: instance method of GitHubAuth
Returns: String | null - The authentication type or null if not found
Checks if a GitHub token is valid and not expired
Kind: instance method of GitHubAuth
Returns: Array - [isValid, statusObject, userData]
| Param | Type | Description |
|---|---|---|
| token | String |
The GitHub token to check |
Gets an access token using the GitHub device flow
Kind: instance method of GitHubAuth
Returns: Object - The access token object
Verifies if the access token is valid and gets a new one if needed
Kind: instance method of GitHubAuth
Returns: Array - [success, statusObject, tokenData]
| Param | Type | Default | Description |
|---|---|---|---|
| saveToConfig | Boolean |
true |
Whether to save to the configuration file, default is true |
github.js
Requires: module:octokit
Version: 3.0.0
Author: Michael Hay michael.hay@mediumroast.io
License: Apache-2.0
Copyright: 2025 Mediumroast, Inc. All rights reserved.
Example
const gitHubCtl = new GitHubFunctions(accessToken, myOrgName, 'mr-cli-setup')
const createRepoResp = await gitHubCtl.createRepository()- GitHubFunctions
- ~getUser() ⇒
Array - ~getAllUsers() ⇒
Array - ~getActionsBillings() ⇒
Array - ~getStorageBillings() ⇒
Array - ~createRepository() ⇒
Array - ~getGitHubOrg() ⇒
Array - ~getWorkflowRuns() ⇒
Array - ~getRepoSize() ⇒
Array - ~createContainers() ⇒
Array - ~createBranchFromMain() ⇒
Promise.<Array> - ~mergeBranchToMain(branchName, mySha, [commitDescription]) ⇒
Promise.<Array> - ~checkForLock(containerName) ⇒
Promise.<Array> - ~lockContainer(containerName) ⇒
Promise.<Array> - ~unlockContainer(containerName, commitSha, branchName) ⇒
Promise.<Array> - ~writeObject(containerName, obj, ref, mySha) ⇒
Promise.<Array> - ~readObjects(containerName) ⇒
Promise.<Array> - ~updateObject(containerName, objName, key, value, [dontWrite], [system], [whiteList]) ⇒
Promise.<Array> - ~deleteObject(objName, source, repoMetadata, catchIt) ⇒
Promise.<Array> - ~catchContainer(repoMetadata) ⇒
Promise.<Array> - ~releaseContainer(repoMetadata) ⇒
Promise.<Array>
- ~getUser() ⇒
Gets the authenticated user from the GitHub API
Kind: inner method of GitHubFunctions
Returns: Array - An array with position 0 being boolean to signify success/failure and position 1 being the user info or error message.
Gets all of the users from the GitHub API
Kind: inner method of GitHubFunctions
Returns: Array - An array with position 0 being boolean to signify success/failure and position 1 being the user info or error message.
Gets the complete billing status for actions from the GitHub API
Kind: inner method of GitHubFunctions
Returns: Array - An array with position 0 being boolean to signify success/failure and position 1 being the user info or error message.
Gets the complete billing status for actions from the GitHub API
Kind: inner method of GitHubFunctions
Returns: Array - An array with position 0 being boolean to signify success/failure and position 1 being the user info or error message.
Creates a repository, at the organization level, for keeping track of all mediumroast.io assets
Kind: inner method of GitHubFunctions
Returns: Array - An array with position 0 being boolean to signify success/failure and position 1 being the created repo or error message.
If the GitHub organization exists retrieves the detail about it and returns to the caller
Kind: inner method of GitHubFunctions
Returns: Array - An array with position 0 being boolean to signify success/failure and position 1 being the org or error message.
Gets all of the workflow runs for the repository
Kind: inner method of GitHubFunctions
Returns: Array - An array with position 0 being boolean to signify success/failure and position 1 being the response or error message.
Gets the size of the repository in MB
Kind: inner method of GitHubFunctions
Returns: Array - An array with position 0 being boolean to signify success/failure and position 1 being the response or error message.
Creates the top level Study, Company and Interaction containers for all mediumroast.io assets
Kind: inner method of GitHubFunctions
Returns: Array - An array with position 0 being boolean to signify success/failure and position 1 being the responses or error messages.
Creates a new branch from the main branch.
Kind: inner method of GitHubFunctions
Returns: Promise.<Array> - A promise that resolves to an array containing a boolean indicating success, a message, and the response.
Merges a specified branch into the main branch by creating a pull request.
Kind: inner method of GitHubFunctions
Returns: Promise.<Array> - A promise that resolves to an array containing success status, message, and response.
| Param | Type | 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 |
"'Performed CRUD operation on objects.'" |
The description of the commit. |
Checks to see if a container is locked.
Kind: inner method of GitHubFunctions
Returns: Promise.<Array> - A promise that resolves to an array containing status and message.
| Param | Type | Description |
|---|---|---|
| containerName | string |
The name of the container to check for a lock. |
Locks a container by creating a lock file in the container.
Kind: inner method of GitHubFunctions
Returns: Promise.<Array> - A promise that resolves to an array containing status and message.
| Param | Type | Description |
|---|---|---|
| containerName | string |
The name of the container to lock. |
Unlocks a container by deleting the lock file in the container.
Kind: inner method of GitHubFunctions
Returns: Promise.<Array> - A promise that resolves to an array containing status and message.
| Param | 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. |
Writes an object to a specified container using the GitHub API.
Kind: inner method of GitHubFunctions
Returns: Promise.<Array> - Status, message, and response
| Param | 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. |
Reads objects from a specified container using the GitHub API.
Kind: inner method of GitHubFunctions
Returns: Promise.<Array> - Status, message, and contents
| Param | Type | Description |
|---|---|---|
| containerName | string |
The name of the container to read objects from. |
GitHubFunctions~updateObject(containerName, objName, key, value, [dontWrite], [system], [whiteList]) ⇒ Promise.<Array>
Updates an object in a specified container
Kind: inner method of GitHubFunctions
Returns: Promise.<Array> - Status, message, and response
| Param | Type | 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 |
false |
A flag to indicate if the object should be written back |
| [system] | boolean |
false |
A flag to indicate if the update is a system call |
| [whiteList] | Array |
[] |
A list of keys that are allowed to be updated |
Deletes an object from a specified container
Kind: inner method of GitHubFunctions
Returns: Promise.<Array> - Status, message, and response
| Param | 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 |
Catches a container by locking it, creating a new branch, reading the objects
Kind: inner method of GitHubFunctions
Returns: Promise.<Array> - Status, message, and metadata
| Param | Type | Description |
|---|---|---|
| repoMetadata | Object |
The metadata object |
Releases a container by unlocking it and merging the branch
Kind: inner method of GitHubFunctions
Returns: Promise.<Array> - Status, message, and response
| Param | Type | Description |
|---|---|---|
| repoMetadata | Object |
The metadata object |
gitHubServer.js
Version: 3.0.0
Author: Michael Hay michael.hay@mediumroast.io
License: Apache-2.0
Copyright: 2025 Mediumroast, Inc. All rights reserved.
For information about the intelligent .gitkeep file management and cleanup functionality, see:
This functionality addresses production issues with stale .gitkeep files and provides automated cleanup for GitHub Actions installations.
Enhanced search capabilities for BaseObjects with fuzzy (partial string) matching support:
This enhancement allows for partial string matching in findByName() and findByX() methods, making object discovery more flexible and user-friendly.