Skip to content

A cli for accessing metadata about pull requests within github actions

License

Notifications You must be signed in to change notification settings

bbeesley/pr-metadata

Repository files navigation

Build, Test & Publish Main

@beesley/pr-metadata

A tool for reading information about pull requests within github actions. Works as a cli or as a node module. Expects a GITHUB_TOKEN env var to be set.

CLI Usage

npx @beesley/pr-metadata --help
# Options:
#   --help      Show help                                                                       [boolean]
#   --version   Show version number                                                             [boolean]
#   --dirNames  Whether to return directory names instead of file names                         [boolean] [default: false]
#   --json      Whether to return result as a json string                                       [boolean] [default: true]
#   --filter    An array of globs to act as an include filter for where we look for changes     [array]

npx @beesley/pr-metadata
# [".commitlintrc.json","src/__mocks__/mock-context.json","src/__mocks__/push-event.json","src/get-changed-files.test.ts","src/get-changed-files.ts","src/index.ts"]

npx @beesley/pr-metadata --json false
# [
#   '.commitlintrc.json',
#   'src/__mocks__/mock-context.json',
#   'src/__mocks__/push-event.json',
#   'src/get-changed-files.test.ts',
#   'src/get-changed-files.ts',
#   'src/index.ts'
# ]

npx @beesley/pr-metadata --dirNames
# ["bin","src/__mocks__","src"]

npx @beesley/pr-metadata --dirNames --filter '**' --filter '!**/__mocks__/**'
# ["bin","src"]

npx @beesley/pr-metadata --filter 'src/**'
# ["src/__mocks__/mock-context.json","src/__mocks__/push-event.json","src/get-changed-files.test.ts","src/get-changed-files.ts","src/index.ts"]

API

Table of Contents

getChangedFiles

src/get-changed-files.ts:13-17

Uses github actions metadata to get a list of changes files or directories

Parameters

  • json boolean Whether or not to return json
  • dirNames boolean Whether or not to return only directory names
  • filter Array<string>? Filter globs to filter results using

Returns any {(Promise<string | string[]>)} The changed files or directories

About

A cli for accessing metadata about pull requests within github actions

Resources

License

Stars

Watchers

Forks

Packages

No packages published