github-comment

CLI to create and hide GitHub comments

MIT License

Stars
88

Bot releases are hidden (Show)

github-comment - v4.0.0

Published by suzuki-shunsuke about 3 years ago

https://github.com/suzuki-shunsuke/github-comment/compare/v3.1.0...v4.0.0
milestone

Breaking Change

#283 No variable becomes embedded in comment by default.

Feature

#283 Add the configuration field embeded_var_names to post and exec config

post:
  hello:
    template: "Hello {{.Vars.name}}"
    embedded_var_names:
      - name # Only `.Vars.name` is embedded into the comment
exec:
  hello:
    - when: true
      template: "Hello {{.Vars.name}}"
      embedded_var_names:
        - name # Only `.Vars.name` is embedded into the comment

Add the configuration field embeded_var_names to post and exec config

github-comment embedds the metadata into the comment to hide the comment by the metadata.
With github-comment v3, all variables are embedded into the comment, but sometimes this behaviour is undesirable.
With github-comment v4, only variables specified by embedded_var_names are embedded into the comment.

github-comment - v4.0.0-0

Published by suzuki-shunsuke over 3 years ago

https://github.com/suzuki-shunsuke/github-comment/compare/v3.1.0...v4.0.0-0
milestone

Breaking Change

#283 No variable becomes embedded in comment by default.

Feature

#283 Add the configuration field embeded_var_names to post and exec config

post:
  hello:
    template: "Hello {{.Vars.name}}"
    embedded_var_names:
      - name # Only `.Vars.name` is embedded into the comment
exec:
  hello:
    - when: true
      template: "Hello {{.Vars.name}}"
      embedded_var_names:
        - name # Only `.Vars.name` is embedded into the comment

Add the configuration field embeded_var_names to post and exec config

github-comment embedds the metadata into the comment to hide the comment by the metadata.
With github-comment v3, all variables are embedded into the comment, but sometimes this behaviour is undesirable.
With github-comment v4, only variables specified by embedded_var_names are embedded into the comment.

github-comment - v3.1.0

Published by suzuki-shunsuke over 3 years ago

https://github.com/suzuki-shunsuke/github-comment/compare/v3.0.1...v3.1.0
milestone

Features

#134 #237 support to configure complement
#245 add -condition option to hide command
#246 #247 add vars to complement
#281 #277 add the -var-file option to the post and exec command

Support to configure complement

#134 #237

Support other platforms with complement configuration.

complement:
  pr:
  - type: envsubst
    value: '${GOOGLE_CLOUD_BUILD_PR_NUMBER}'
  org:
  - type: envsubst
    value: 'suzuki-shunsuke'
  repo:
  - type: envsubst
    value: '${GOOGLE_CLOUD_BUILD_REPO_NAME}'
  sha1:
  - type: envsubst
    value: '${GOOGLE_CLOUD_BUILD_COMMIT_SHA}'

The following types are supported.

Add -condition option to hide command

#245

Support to specify the condition with -condition option.

$ github-comment hide -condition 'Comment.Body contains "foo"'

Add vars to complement

#246 #247

complement:
  vars:
    yoo: # the variable "yoo" is added to "vars"
    - type: template
      value: '{{env "YOO"}}'

add the -var-file option to the post and exec command

$ github-comment post -var-file content:foo.txt
$ github-comment exec -var-file content:foo.txt -- echo hello
github-comment - v3.1.0-3

Published by suzuki-shunsuke over 3 years ago

github-comment - v3.1.0-2

Published by suzuki-shunsuke over 3 years ago

github-comment - v3.1.0-1

Published by suzuki-shunsuke over 3 years ago

github-comment - v3.1.0-0

Published by suzuki-shunsuke over 3 years ago

https://github.com/suzuki-shunsuke/github-comment/compare/v3.0.1...v3.1.0-0
milestone

Features

#134 #237 support to configure complement
#245 add -condition option to hide command
#246 #247 add vars to complement

Support to configure complement

#134 #237

Support other platforms with complement configuration.

complement:
  pr:
  - type: envsubst
    value: '${GOOGLE_CLOUD_BUILD_PR_NUMBER}'
  org:
  - type: envsubst
    value: 'suzuki-shunsuke'
  repo:
  - type: envsubst
    value: '${GOOGLE_CLOUD_BUILD_REPO_NAME}'
  sha1:
  - type: envsubst
    value: '${GOOGLE_CLOUD_BUILD_COMMIT_SHA}'

The following types are supported.

Add -condition option to hide command

#245

Support to specify the condition with -condition option.

$ github-comment hide -condition 'Comment.Body contains "foo"'

Add vars to complement

#246 #247

complement:
  vars:
    yoo: # the variable "yoo" is added to "vars"
    - type: template
      value: '{{env "YOO"}}'
github-comment - v3.0.1

Published by suzuki-shunsuke over 3 years ago

github-comment - v3.0.0

Published by suzuki-shunsuke over 3 years ago

https://github.com/suzuki-shunsuke/github-comment/compare/v2.2.0...v3.0.0
milestone

Improve the way to hide comments

Motivation

The feature to hide comments was introduced in v2.1.0,
but we found the specificaiton has some problems.
It is inefficient to get comments and extract hidden comments from them several times.
So in v3, we improve the way to hide comments. This includes breaking changes.
Instead of hiding comments in post and exec command, we should call hide command in the begging of the CI.

Breaking Changes

#210 a HTML comment is embedded to a comment
#210 remove the feature to hide comments in post and exec command

ex.

<!-- github-comment: {"SHA1":"79acc0778da6660712a65fd41a48b72cb7ad16c1","TemplateKey":"default","JobID":"xxx","JobName":"plan"} -->

Features

#205 #210 add a command "hide" and embed meta data to comment
#212 output info logs about comment hidden
#215 feat: get the pull request number from CI_INFO_PR_NUMBER

add a command "hide" and embed meta data to comment

$ github-comment hide

hide config

ex.

---
hide:
  plan: 'Comment.HasMeta && (Comment.Meta.SHA1 != Commit.SHA1 || Comment.Meta.Vars.target == "foo")'
$ github-comment hide -k plan

Embeded meta data

  • SHA1
  • TemplateKey
  • Vars
  • JobID (optional)
  • JobName (optional)
  • WorkflowName (optional)

These meta data can be referred in hide condition as Comment.Meta.

get the pull request number from CI_INFO_PR_NUMBER

The environment variable CI_INFO_PR_NUMBER is set by ci-info by default.
If the pull request number can't be gotten from platform's built-in environment variables but CI_INFO_PR_NUMBER is set, github-comment uses CI_INFO_PR_NUMBER.

github-comment - v3.0.0-4

Published by suzuki-shunsuke over 3 years ago

Changelog

de84d0b build: update version to v3.0.0-4

github-comment - v3.0.0-3

Published by suzuki-shunsuke over 3 years ago

https://github.com/suzuki-shunsuke/github-comment/compare/v3.0.0-2...v3.0.0-3
milestone

Features

#215 feat: get the pull request number from CI_INFO_PR_NUMBER

The environment variable CI_INFO_PR_NUMBER is set by ci-info by default.
If the pull request number can't be gotten from platform's built-in environment variables but CI_INFO_PR_NUMBER is set, github-comment uses CI_INFO_PR_NUMBER.

github-comment - v3.0.0-2

Published by suzuki-shunsuke over 3 years ago

https://github.com/suzuki-shunsuke/github-comment/compare/v3.0.0-1...v3.0.0-2
milestone

Fixes

#213 #214 validate whether pull request number is set

To hide issue or pull request comments, the pull request or issue number is required.

github-comment - v3.0.0-1

Published by suzuki-shunsuke over 3 years ago

https://github.com/suzuki-shunsuke/github-comment/compare/v3.0.0-0...v3.0.0-1
milestone

Features

#212 output info logs about comment hidden

Fixes

#212 fix the parameter of the expression to hide comments

Docs

#211 update README

github-comment - v3.0.0-0

Published by suzuki-shunsuke over 3 years ago

https://github.com/suzuki-shunsuke/github-comment/compare/v2.2.0...v3.0.0-0
milestone

Improve the way to hide comments

Motivation

The feature to hide comments was introduced in v2.1.0,
but we found the specificaiton has some problems.
It is inefficient to get comments and extract hidden comments from them several times.
So in v3, we improve the way to hide comments. This includes breaking changes.
Instead of hiding comments in post and exec command, we should call hide command in the begging of the CI.

Breaking Changes

#210 a HTML comment is embedded to a comment
#210 remove the feature to hide comments in post and exec command

ex.

<!-- github-comment: {"SHA1":"79acc0778da6660712a65fd41a48b72cb7ad16c1","TemplateKey":"default","JobID":"xxx","JobName":"plan"} -->

Features

#205 #210 feat: add a command "hide" and embed meta data to comment

$ github-comment hide

hide config

ex.

---
hide:
  plan: 'Comment.HasMeta && (Comment.Meta.SHA1 != Commit.SHA1 || Comment.Meta.Vars.target == "foo")'
$ github-comment hide -k plan

Embeded meta data

  • SHA1
  • TemplateKey
  • Vars
  • JobID (optional)
  • JobName (optional)
  • WorkflowName (optional)

These meta data can be referred in hide condition as Comment.Meta.

github-comment - v2.2.0

Published by suzuki-shunsuke almost 4 years ago

Changelog

https://github.com/suzuki-shunsuke/github-comment/compare/v2.1.0...v2.2.0
milestone

Features

#202 #203 feat: remove color escape sequence

Example

$ github-comment exec -- terraform plan -detailed-exitcode

Of course we know the option -no-color of terraform plan.
This is just example.

AS IS

[0m[1mRefreshing Terraform state in-memory prior to plan...[0m
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
[0m
[0m[1mnull_resource.foo: Refreshing state... [id=3982188145624120504][0m

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  [32m+[0m create
  [31m-[0m destroy
[0m
Terraform will perform the following actions:

[1m  # null_resource.bar[0m will be created[0m[0m
[0m  [32m+[0m[0m resource "null_resource" "bar" {
      [32m+[0m [0m[1m[0mid[0m[0m = (known after apply)
    }

[1m  # null_resource.foo[0m will be [1m[31mdestroyed[0m[0m
[0m  [31m-[0m[0m resource "null_resource" "foo" {
      [31m-[0m [0m[1m[0mid[0m[0m = "3982188145624120504" [90m->[0m [0m[90mnull[0m[0m
    }

[0m[1mPlan:[0m 1 to add, 0 to change, 1 to destroy.[0m

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

TO BE

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

null_resource.foo: Refreshing state... [id=3982188145624120504]

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create
  - destroy

Terraform will perform the following actions:

  # null_resource.bar will be created
  + resource "null_resource" "bar" {
      + id = (known after apply)
    }

  # null_resource.foo will be destroyed
  - resource "null_resource" "foo" {
      - id = "3982188145624120504" -> null
    }

Plan: 1 to add, 0 to change, 1 to destroy.

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
github-comment - v2.1.0

Published by suzuki-shunsuke almost 4 years ago

Changelog

https://github.com/suzuki-shunsuke/github-comment/compare/v2.0.1...v2.1.0
milestone

Features

#187 #189 #193 #195 #196 #198 #199 #200 feat: support to hide existing comments
#190 feat: support --log-level option and structured logging with logrus

feat: support to hide existing comments

When github-comment is used at CI, github-comment posts a comment at every builds.
So many same comments would be posted.
Sometimes old comments are noisy, so we want to hide them.

By configuring hide_old_comment, we can hide old comments.
hide_old_comment is an expr expression, and comments which match this condition would be hidden.

post:
  foo:
    template: foo
    hide_old_comment: Comment.Body contains "foo" # hide existing comments which includes `foo`
exec:
  foo:
  - when: ExitCode != 0
    template: foo
    hide_old_comment: Comment.Body contains "foo" # hide existing comments which includes `foo`

If hide_old_comment isn't set, no comment is hidden.

Wa can use HTML comment to hide comments.

post:
  foo:
    template: |
      {{"<!-- github-comment:foo-" | AvoidHTMLEscape}}{{env "TARGET"}}{{" -->" | AvoidHTMLEscape}}
      foo {{env "TARGET"}}
    hide_old_comment: |
      Comment.Body contains "<!-- github-comment:foo-" + Env("TARGET") + " -->"

In case of post command, we can use the following variables in hide_old_comment.

  • Commit
    • Org
    • Repo
    • PRNumber
    • SHA1
  • Comment: judge whether this comment should be hidden
    • Body
  • PostedComment: a comment which will be posted
    • Body
    • TemplateKey
  • Vars: template variables

In addition to above variables, we can use the following variables in case of exec command.

  • Command
    • ExitCode
    • Stdout
    • Stderr
    • CombinedOutput
    • Command
    • JoinCommand
github-comment - v2.1.0-5

Published by suzuki-shunsuke almost 4 years ago

Changelog

https://github.com/suzuki-shunsuke/github-comment/compare/v2.1.0-4...v2.1.0-5
milestone

Fix

#200 fix: rename "minimize" to "hide_old_comment"

github-comment - v2.1.0-4

Published by suzuki-shunsuke almost 4 years ago

Changelog

https://github.com/suzuki-shunsuke/github-comment/compare/v2.1.0-3...v2.1.0-4
milestone

Fix

#199 fix: ignore error to get an authenticated user

github-comment - v2.1.0-3

Published by suzuki-shunsuke almost 4 years ago

Changelog

https://github.com/suzuki-shunsuke/github-comment/compare/v2.1.0-2...v2.1.0-3
milestone

Fix

#196 fix: post a comment even if it failed to list hidden comments
#198 fix: don't filter commits by login when login is empty

github-comment - v2.1.0-2

Published by suzuki-shunsuke almost 4 years ago

Package Rankings
Top 7.75% on Proxy.golang.org
Badges
Extracted from project README
Build Status Go Report Card GitHub last commit License