Skip to content

This library is a wrapper library that can be used to execute actions in Github Actions.

Notifications You must be signed in to change notification settings

MarkusRissmann-private/githubclient

Repository files navigation

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

About

This library is a wrapper library that can be used to execute actions in Github Actions.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published