github-comment

module
v0.2.0-0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2020 License: MIT

README

github-comment

Build Status codecov Go Report Card GitHub last commit License

CLI to create a GitHub comment with GitHub REST API

Usage

$ github-comment version
$ github-comment help
# comment to a commit
$ github-comment post [-token <token>] [-org <org>] [-repo <repo>] [-revision <revision>] [-template <template>]
# comment to a pull request
$ github-comment post [-token <token>] [-org <org>] [-repo <repo>] [-pr <pr number>] [-template <template>]
$ echo "<comment>" | github-comment post [-token <token>] [-org <org>] [-repo <repo>] [-pr <pr number>]
$ github-comment exec [-token <token>] [-org <org>] [-repo <repo>] [-revision <revision>] [-template-key <template key>] -- <command>
$ github-comment exec -- echo hello

Configuration

---
post:
  # <template key>:
  default: |
    {{.Org}}/{{.Repo}}
    {{.PRNumber}}
    {{.SHA1}}
    {{.TemplateKey}}
    CIRCLE_PULL_REQUEST: {{Env "CIRCLE_PULL_REQUEST"}}
exec:
  # <template key>:
  default: # default configuration
    # https://github.com/antonmedv/expr/blob/master/docs/Language-Definition.md
    - when: ExitCode != 0
      # https://golang.org/pkg/text/template/
      template: |
        command: {{.Command}}
        exit code: {{.ExitCode}}
        stdout: {{.Stdout}}
        stderr: {{.Stderr}}
        combined output: {{.CombinedOutput}}
        CIRCLE_PULL_REQUEST: {{Env "CIRCLE_PULL_REQUEST"}}
    - when: ExitCode == 0
      dont_comment: true
  hello:
    - when: true
      template: hello
post: variables which can be used in template
  • Org
  • Repo
  • PRNumber
  • SHA1
  • TemplateKey
exec: variables which can be used in when and template

Options

  • token: GitHub API token to create a comment
  • org: GitHub organization name
  • repo: GitHub repository name
  • revision: commit SHA
  • pr: pull request number
  • template: comment text
  • template key: template key

Support standard input to pass a template

Instead of -template, we can pass a template from a standard input.

$ echo hello | github-comment post

Environment variables

  • GITHUB_TOKEN: complement the option token

Support to complement options with CircleCI built-in Environment variables

https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables

  • org: CIRCLE_PROJECT_USERNAME
  • repo: CIRCLE_PROJECT_REPONAME
  • pr: CIRCLE_PULL_REQUEST
  • revision: CIRCLE_SHA

License

MIT

Directories

Path Synopsis
cmd
github-comment command
pkg
api
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL