8000 GitHub - joshdk/drone-github-comment: 💬 Drone plugin which takes the output of a step and comments on a Github pull request
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

💬 Drone plugin which takes the output of a step and comments on a Github pull request

License

Notifications You must be signed in to change notification settings

joshdk/drone-github-comment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License Actions Releases

Drone Github Comment Plugin

💬 Drone plugin which takes the output of a step and comments on a Github pull request

pull request comment

Motivations

This DroneCI plugin enables you to take the output from a target step and comment that output as a GitHub pull request comment. This enables you to write single purpose steps that lint files, run tests, etc, that don't require any knowledge of the underlying pull request or the GitHub API.

Usage

This plugin can be added to your .drone.yml as a new step within an existing pipeline. Secrets for a DRONE_TOKEN as well as a GITHUB_TOKEN must be configured.

steps:
- name: drone-github-comment
  image: ghcr.io/joshdk/drone-github-comment:v0.3.0
  environment:
    DRONE_TOKEN:
      from_secret: DRONE_TOKEN
    GITHUB_TOKEN:
      from_secret: GITHUB_TOKEN

You then need to configure a target step name that refers to existing pipeline step. You can either specify both the stage/step name, like build-pull-request/lint-code in the example below, or just the step name for convenience.

kind: pipeline
name: build-pull-request
steps:
- name: lint-code
  commands:
  - "golangci-lint run ."

- name: drone-github-comment
  image: ghcr.io/joshdk/drone-github-comment:v0.3.0
  settings:
    step: build-pull-request/lint-code
    #step: lint-code

You must also configure the depends_on values, since this plugin must be run after the target step finishes.

steps:
- name: drone-github-comment
  image: ghcr.io/joshdk/drone-github-comment:v0.3.0
  depends_on:
  - lint-code

You should also configure the when values, since this plugin might be run after the target step fails.

steps:
- name: drone-github-comment
  image: ghcr.io/joshdk/drone-github-comment:v0.3.0
  when:
    status:
      - failure

Comments posted by previous runs are considered out of date, and are automatically deleted on subsequent runs. To avoid the deletion of out of date comments, you can set keep to true.

steps:
- name: drone-github-comment
  image: ghcr.io/joshdk/drone-github-comment:v0.3.0
  settings:
    keep: true

You may want to only post a comment when the target step succeeds or fails. You can use set when to success, failure, or always. This setting defaults to always. Note that the when setting is different to the when step property.

steps:
- name: drone-github-comment
  image: ghcr.io/joshdk/drone-github-comment:v0.3.0
  settings:
    when: failure

Target steps often run a series of shell commands, which print each command run using set -e. These lines, which start with a + symbol, are automatically ignored. To include such lines, you can set verbatim to true.

steps:
- name: drone-github-comment
  image: ghcr.io/joshdk/drone-github-comment:v0.3.0
  settings:
    verbatim: true

License

This code is distributed under the MIT License, see LICENSE.txt for more information.

0