Skip to content

Latest commit

 

History

History
79 lines (56 loc) · 2.1 KB

README.md

File metadata and controls

79 lines (56 loc) · 2.1 KB

github-actions-client

Known Vulnerabilities Coverage lines

This library is a Wrapper library that uses Octokit in the background. Currently you can use it to create, update and delete repository secrets and repository variables. Workflow dispatch events can be triggered with it. Also workflows can be loaded, activated or deactivated.

Installation

npm

npm i github-actions-client 

yarn

yarn add github-actions-client

Usage


import { GithubActionsClient } from 'github-actions-client'

const github_username = 'username';
const github_repository = 'repository';

async function main(): Promise<void> {
  try {
    const ghc = new GithubActionsClient(github_username, github_repository);

    await ghc.CreateOrUpdateSecret('SecretName1', 'SecretValue1');
    await ghc.CreateOrUpdateSecret('SecretName2', 'SecretValue2');
    await ghc.CreateOrUpdateRepositoryVariable('VariableName1', 'eu-central-1');
    await ghc.CreateOrUpdateRepositoryVariable('VariableName2', '1');
   

    await ghc.TriggerWorkflow(/*wokflow name */ 'main', /* branch */ 'main');
  } catch (err: any) {
    throw err;
  }
}

main()
  .then()
  .catch((err) => {
    console.error(err.message);
  });

The GithubActionsClient constructor


constructor(
  github_username: string, 
  github_repository: string, 
  githubToken?: string, 
  apiVersion?: string) {...}

github_username -> Your github username.

github_repository -> Repository where the actions should be performed.

githubToken -> (optional) Your personal token. If not provided the environment variable GITHUB_TOKEN will be used.

api Version -> (optional) A specific API version. If not provided '2022-11-28' will be used . Project is tested with this version


Code Documentation

GithubActionsClient