docs: add parameter documentation (#69)

This commit is contained in:
Robert Kaussow 2021-09-12 15:16:43 +02:00 committed by GitHub
parent 4402ccf211
commit 27cba92c61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 344 additions and 241 deletions

5
.dictionary Normal file
View File

@ -0,0 +1,5 @@
api
github
url
gh
drone-github-comment

View File

@ -235,6 +235,61 @@ local PipelineBuildContainer(arch='amd64') = {
}, },
}; };
local PipelineDocs = {
kind: 'pipeline',
name: 'docs',
platform: {
os: 'linux',
arch: 'amd64',
},
concurrency: {
limit: 1,
},
steps: [
{
name: 'markdownlint',
image: 'thegeeklab/markdownlint-cli',
commands: [
"markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md'",
],
},
{
name: 'spellcheck',
image: 'node:lts-alpine',
commands: [
'npm install -g spellchecker-cli',
"spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions",
],
environment: {
FORCE_COLOR: true,
NPM_CONFIG_LOGLEVEL: 'error',
},
},
{
name: 'publish',
image: 'plugins/gh-pages',
settings: {
username: { from_secret: 'github_username' },
password: { from_secret: 'github_token' },
pages_directory: '_docs/',
target_branch: 'docs',
},
when: {
ref: ['refs/heads/main'],
},
},
],
depends_on: [
'build-binaries',
'build-container-amd64',
'build-container-arm64',
'build-container-arm',
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
},
};
local PipelineNotifications = { local PipelineNotifications = {
kind: 'pipeline', kind: 'pipeline',
image_pull_secrets: ['docker_config'], image_pull_secrets: ['docker_config'],
@ -283,7 +338,7 @@ local PipelineNotifications = {
from_secret: 'docker_username', from_secret: 'docker_username',
}, },
PUSHRM_FILE: 'README.md', PUSHRM_FILE: 'README.md',
PUSHRM_SHORT: 'Drone plugin to add comments to GitHub Issues/PRs', PUSHRM_SHORT: 'Drone plugin to add comments to GitHub Issues and Pull Requests',
PUSHRM_TARGET: 'thegeeklab/${DRONE_REPO_NAME}', PUSHRM_TARGET: 'thegeeklab/${DRONE_REPO_NAME}',
}, },
when: { when: {
@ -320,10 +375,7 @@ local PipelineNotifications = {
}, },
], ],
depends_on: [ depends_on: [
'build-binaries', 'docs',
'build-container-amd64',
'build-container-arm',
'build-container-arm64',
], ],
trigger: { trigger: {
ref: ['refs/heads/main', 'refs/tags/**'], ref: ['refs/heads/main', 'refs/tags/**'],
@ -337,5 +389,6 @@ local PipelineNotifications = {
PipelineBuildContainer(arch='amd64'), PipelineBuildContainer(arch='amd64'),
PipelineBuildContainer(arch='arm64'), PipelineBuildContainer(arch='arm64'),
PipelineBuildContainer(arch='arm'), PipelineBuildContainer(arch='arm'),
PipelineDocs,
PipelineNotifications, PipelineNotifications,
] ]

View File

@ -1,106 +1,96 @@
--- ---
kind: pipeline
name: test
platform:
os: linux
arch: amd64
steps:
- name: staticcheck
image: golang:1.16
commands:
- go run honnef.co/go/tools/cmd/staticcheck ./...
volumes:
- name: gopath
path: /go
- name: lint
image: golang:1.16
commands:
- go run golang.org/x/lint/golint -set_exit_status ./...
volumes:
- name: gopath
path: /go
- name: vet
image: golang:1.16
commands:
- go vet ./...
volumes:
- name: gopath
path: /go
- name: test
image: golang:1.16
commands:
- go test -cover ./...
volumes:
- name: gopath
path: /go
volumes:
- name: gopath
temp: {}
image_pull_secrets: image_pull_secrets:
- docker_config - docker_config
kind: pipeline
name: test
platform:
arch: amd64
os: linux
steps:
- commands:
- go run honnef.co/go/tools/cmd/staticcheck ./...
image: golang:1.16
name: staticcheck
volumes:
- name: gopath
path: /go
- commands:
- go run golang.org/x/lint/golint -set_exit_status ./...
image: golang:1.16
name: lint
volumes:
- name: gopath
path: /go
- commands:
- go vet ./...
image: golang:1.16
name: vet
volumes:
- name: gopath
path: /go
- commands:
- go test -cover ./...
image: golang:1.16
name: test
volumes:
- name: gopath
path: /go
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
volumes:
- name: gopath
temp: {}
--- ---
depends_on:
- test
image_pull_secrets:
- docker_config
kind: pipeline kind: pipeline
name: build-binaries name: build-binaries
platform: platform:
os: linux
arch: amd64 arch: amd64
os: linux
steps: steps:
- name: build - commands:
image: techknowlogick/xgo:go-1.16.x - '[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}'
commands:
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
- mkdir -p release/ - mkdir -p release/
- cd cmd/drone-github-comment && xgo -ldflags "-s -w -X main.version=$BUILD_VERSION" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-github-comment . - cd cmd/drone-github-comment && xgo -ldflags "-s -w -X main.version=$BUILD_VERSION"
-tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-github-comment
.
- mv /build/* /drone/src/release/ - mv /build/* /drone/src/release/
- ls -l /drone/src/release/ - ls -l /drone/src/release/
image: techknowlogick/xgo:go-1.16.x
- name: executable name: build
image: alpine - commands:
commands:
- $(find release/ -executable -type f | grep drone-github-comment-linux-amd64) --help - $(find release/ -executable -type f | grep drone-github-comment-linux-amd64) --help
- name: compress
image: alpine image: alpine
commands: name: executable
- commands:
- apk add upx - apk add upx
- find release/ -maxdepth 1 -executable -type f -exec upx {} \; - find release/ -maxdepth 1 -executable -type f -exec upx {} \;
- ls -lh release/ - ls -lh release/
- name: checksum
image: alpine image: alpine
commands: name: compress
- commands:
- cd release/ && sha256sum * > sha256sum.txt - cd release/ && sha256sum * > sha256sum.txt
image: alpine
- name: changelog-generate name: checksum
image: thegeeklab/git-chglog - commands:
commands:
- git fetch -tq - git fetch -tq
- git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased} - git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased
unreleased}
- name: changelog-format image: thegeeklab/git-chglog
image: thegeeklab/alpine-tools name: changelog-generate
commands: - commands:
- prettier CHANGELOG.md - prettier CHANGELOG.md
- prettier -w CHANGELOG.md - prettier -w CHANGELOG.md
image: thegeeklab/alpine-tools
- name: publish name: changelog-format
image: plugins/github-release - image: plugins/github-release
name: publish
settings: settings:
api_key: api_key:
from_secret: github_token from_secret: github_token
@ -112,36 +102,32 @@ steps:
when: when:
ref: ref:
- refs/tags/** - refs/tags/**
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
---
depends_on: depends_on:
- test - test
image_pull_secrets:
--- - docker_config
kind: pipeline kind: pipeline
name: build-container-amd64 name: build-container-amd64
platform: platform:
os: linux
arch: amd64 arch: amd64
os: linux
steps: steps:
- name: build - commands:
- '[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}'
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/amd64/drone-github-comment
./cmd/drone-github-comment
image: golang:1.16 image: golang:1.16
commands: name: build
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - depends_on:
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/amd64/drone-github-comment ./cmd/drone-github-comment - build
- name: dryrun
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
name: dryrun
settings: settings:
config: config:
from_secret: docker_config from_secret: docker_config
@ -155,11 +141,10 @@ steps:
when: when:
ref: ref:
- refs/pull/** - refs/pull/**
depends_on: - depends_on:
- build - dryrun
- name: publish-dockerhub
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
name: publish-dockerhub
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: amd64 auto_tag_suffix: amd64
@ -175,11 +160,10 @@ steps:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
depends_on: - depends_on:
- dryrun - dryrun
- name: publish-quay
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
name: publish-quay
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: amd64 auto_tag_suffix: amd64
@ -196,38 +180,32 @@ steps:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
depends_on:
- dryrun
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
---
depends_on: depends_on:
- test - test
image_pull_secrets:
--- - docker_config
kind: pipeline kind: pipeline
name: build-container-arm64 name: build-container-arm64
platform: platform:
os: linux
arch: arm64 arch: arm64
os: linux
steps: steps:
- name: build - commands:
- '[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}'
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm64/drone-github-comment
./cmd/drone-github-comment
image: golang:1.16 image: golang:1.16
commands: name: build
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - depends_on:
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm64/drone-github-comment ./cmd/drone-github-comment - build
- name: dryrun
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
name: dryrun
settings: settings:
config: config:
from_secret: docker_config from_secret: docker_config
@ -241,11 +219,10 @@ steps:
when: when:
ref: ref:
- refs/pull/** - refs/pull/**
depends_on: - depends_on:
- build - dryrun
- name: publish-dockerhub
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
name: publish-dockerhub
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: arm64 auto_tag_suffix: arm64
@ -261,11 +238,10 @@ steps:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
depends_on: - depends_on:
- dryrun - dryrun
- name: publish-quay
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
name: publish-quay
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: arm64 auto_tag_suffix: arm64
@ -282,38 +258,32 @@ steps:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
depends_on:
- dryrun
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
---
depends_on: depends_on:
- test - test
image_pull_secrets:
--- - docker_config
kind: pipeline kind: pipeline
name: build-container-arm name: build-container-arm
platform: platform:
os: linux
arch: arm arch: arm
os: linux
steps: steps:
- name: build - commands:
- '[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}'
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm/drone-github-comment
./cmd/drone-github-comment
image: golang:1.16 image: golang:1.16
commands: name: build
- "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}" - depends_on:
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm/drone-github-comment ./cmd/drone-github-comment - build
- name: dryrun
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
name: dryrun
settings: settings:
config: config:
from_secret: docker_config from_secret: docker_config
@ -327,11 +297,10 @@ steps:
when: when:
ref: ref:
- refs/pull/** - refs/pull/**
depends_on: - depends_on:
- build - dryrun
- name: publish-dockerhub
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
name: publish-dockerhub
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: arm auto_tag_suffix: arm
@ -347,11 +316,10 @@ steps:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
depends_on: - depends_on:
- dryrun - dryrun
- name: publish-quay
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
name: publish-quay
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: arm auto_tag_suffix: arm
@ -368,32 +336,68 @@ steps:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
depends_on:
- dryrun
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
depends_on:
- test
--- ---
concurrency:
limit: 1
depends_on:
- build-binaries
- build-container-amd64
- build-container-arm64
- build-container-arm
kind: pipeline
name: docs
platform:
arch: amd64
os: linux
steps:
- commands:
- markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md'
image: thegeeklab/markdownlint-cli
name: markdownlint
- commands:
- npm install -g spellchecker-cli
- spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary
-p spell indefinite-article syntax-urls --no-suggestions
environment:
FORCE_COLOR: true
NPM_CONFIG_LOGLEVEL: error
image: node:lts-alpine
name: spellcheck
- image: plugins/gh-pages
name: publish
settings:
pages_directory: _docs/
password:
from_secret: github_token
target_branch: docs
username:
from_secret: github_username
when:
ref:
- refs/heads/main
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
---
depends_on:
- docs
image_pull_secrets:
- docker_config
kind: pipeline kind: pipeline
name: notifications name: notifications
platform: platform:
os: linux
arch: amd64 arch: amd64
os: linux
steps: steps:
- name: manifest-dockerhub - image: plugins/manifest
image: plugins/manifest name: manifest-dockerhub
settings: settings:
auto_tag: true auto_tag: true
ignore_missing: true ignore_missing: true
@ -405,9 +409,8 @@ steps:
when: when:
status: status:
- success - success
- image: plugins/manifest
- name: manifest-quay name: manifest-quay
image: plugins/manifest
settings: settings:
auto_tag: true auto_tag: true
ignore_missing: true ignore_missing: true
@ -419,10 +422,7 @@ steps:
when: when:
status: status:
- success - success
- environment:
- name: pushrm-dockerhub
image: chko/docker-pushrm:1
environment:
DOCKER_PASS: DOCKER_PASS:
from_secret: docker_password from_secret: docker_password
DOCKER_USER: DOCKER_USER:
@ -430,23 +430,23 @@ steps:
PUSHRM_FILE: README.md PUSHRM_FILE: README.md
PUSHRM_SHORT: Drone plugin to add comments to GitHub Issues/PRs PUSHRM_SHORT: Drone plugin to add comments to GitHub Issues/PRs
PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME} PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME}
image: chko/docker-pushrm:1
name: pushrm-dockerhub
when: when:
status: status:
- success - success
- environment:
- name: pushrm-quay
image: chko/docker-pushrm:1
environment:
APIKEY__QUAY_IO: APIKEY__QUAY_IO:
from_secret: quay_token from_secret: quay_token
PUSHRM_FILE: README.md PUSHRM_FILE: README.md
PUSHRM_TARGET: quay.io/thegeeklab/${DRONE_REPO_NAME} PUSHRM_TARGET: quay.io/thegeeklab/${DRONE_REPO_NAME}
image: chko/docker-pushrm:1
name: pushrm-quay
when: when:
status: status:
- success - success
- image: plugins/matrix
- name: matrix name: matrix
image: plugins/matrix
settings: settings:
homeserver: homeserver:
from_secret: matrix_homeserver from_secret: matrix_homeserver
@ -454,17 +454,15 @@ steps:
from_secret: matrix_password from_secret: matrix_password
roomid: roomid:
from_secret: matrix_roomid from_secret: matrix_roomid
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}" template: 'Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name
}}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message:
{{ build.message }}'
username: username:
from_secret: matrix_username from_secret: matrix_username
when: when:
status: status:
- success - success
- failure - failure
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
@ -472,15 +470,8 @@ trigger:
status: status:
- success - success
- failure - failure
depends_on:
- build-binaries
- build-container-amd64
- build-container-arm
- build-container-arm64
--- ---
kind: signature kind: signature
hmac: 53df9035380e2de0711156ba5f5df747870c7071fdd018be39041616688a9f96 hmac: c1107cd57c9386f653d0c00eb55ffc303ae691c9e99df370a71d4f8597f60235
... ...

12
.github/settings.yml vendored
View File

@ -1,6 +1,7 @@
repository: repository:
name: drone-github-comment name: drone-github-comment
description: Drone plugin to add comments to GitHub Issues/PRs description: Drone plugin to add comments to GitHub Issues and Pull Requests
homepage: https://drone-plugin-index.geekdocs.de/plugins/drone-github-comment
topics: drone, drone-plugin topics: drone, drone-plugin
private: false private: false
@ -53,3 +54,12 @@ branches:
- continuous-integration/drone/pr - continuous-integration/drone/pr
enforce_admins: null enforce_admins: null
restrictions: null restrictions: null
- name: docs
protection:
required_pull_request_reviews: null
required_status_checks: null
enforce_admins: true
restrictions:
users: []
teams:
- bot

6
.markdownlint.yml Normal file
View File

@ -0,0 +1,6 @@
---
default: True
MD013: False
MD041: False
MD004:
style: dash

View File

@ -1,6 +1,6 @@
# drone-github-comment # drone-github-comment
Drone plugin to add comments to GitHub Issues/PRs Drone plugin to add comments to GitHub Issues and Pull Requests
[![Build Status](https://img.shields.io/drone/build/thegeeklab/drone-github-comment?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/drone-github-comment) [![Build Status](https://img.shields.io/drone/build/thegeeklab/drone-github-comment?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/drone-github-comment)
[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/drone-github-comment) [![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/drone-github-comment)
@ -10,41 +10,7 @@ Drone plugin to add comments to GitHub Issues/PRs
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/drone-github-comment) [![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/drone-github-comment)
[![License: MIT](https://img.shields.io/github/license/thegeeklab/drone-github-comment)](https://github.com/thegeeklab/drone-github-comment/blob/main/LICENSE) [![License: MIT](https://img.shields.io/github/license/thegeeklab/drone-github-comment)](https://github.com/thegeeklab/drone-github-comment/blob/main/LICENSE)
Drone plugin to add comments to GitHub Issues/PR's. Drone plugin to add comments to GitHub Issues and Pull Requests. You can find the full documentation at You can find the full documentation at [https://drone-plugin-index.geekdocs.de](https://drone-plugin-index.geekdocs.de/plugins/drone-github-comment).
## Build
Build the binary with the following command:
```Shell
export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on
go build -v -a -tags netgo -o release/drone-github-comment
```
Build the Docker image with the following command:
```Shell
docker build --file docker/Dockerfile.amd64 --tag thegeeklab/drone-github-comment .
```
## Usage
```Shell
docker run --rm \
-e DRONE_BUILD_EVENT=pull_request \
-e DRONE_REPO_OWNER=octocat \
-e DRONE_REPO_NAME=foo \
-e DRONE_PULL_REQUEST=1
-e PLUGIN_API_KEY=abc123 \
-e PLUGIN_MESSAGE="Demo comment" \
-v $(pwd):$(pwd) \
-w $(pwd) \
thegeeklab/drone-github-comment
```
## Contributors ## Contributors

72
_docs/_index.md Normal file
View File

@ -0,0 +1,72 @@
---
title: drone-docker
---
[![Build Status](https://img.shields.io/drone/build/thegeeklab/drone-github-comment?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/drone-github-comment)
[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/drone-github-comment)
[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/drone-github-comment)
[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/drone-github-comment)](https://github.com/thegeeklab/drone-github-comment/graphs/contributors)
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/drone-github-comment)
[![License: MIT](https://img.shields.io/github/license/thegeeklab/drone-github-comment)](https://github.com/thegeeklab/drone-github-comment/blob/main/LICENSE)
Drone plugin to add comments to GitHub Issues and Pull Requests.
<!-- prettier-ignore-start -->
<!-- spellchecker-disable -->
{{< toc >}}
<!-- spellchecker-enable -->
<!-- prettier-ignore-end -->
## Build
Build the binary with the following command:
```Shell
export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on
go build -v -a -tags netgo -o release/drone-github-comment
```
Build the Docker image with the following command:
```Shell
docker build --file docker/Dockerfile.amd64 --tag thegeeklab/drone-github-comment .
```
## Usage
```Shell
docker run --rm \
-e DRONE_BUILD_EVENT=pull_request \
-e DRONE_REPO_OWNER=octocat \
-e DRONE_REPO_NAME=foo \
-e DRONE_PULL_REQUEST=1
-e PLUGIN_API_KEY=abc123 \
-e PLUGIN_MESSAGE="Demo comment" \
-v $(pwd):$(pwd) \
-w $(pwd) \
thegeeklab/drone-github-comment
```
### Parameters
api_key
: sets api key to access github api
base_url
: sets api url; need to be changed for gh enterprise (default `https://api.github.com`)
key
: sets unique key to assign to comment
message
: sets file or string with comment message
update
: enables update of an existing comment that matches the key
skip_missing
: skips comment creation if the given message file does not exist (default `false`)

View File

@ -10,40 +10,40 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
return []cli.Flag{ return []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "api-key", Name: "api-key",
Usage: "api key to access github api",
EnvVars: []string{"PLUGIN_API_KEY", "GITHUB_COMMENT_API_KEY"}, EnvVars: []string{"PLUGIN_API_KEY", "GITHUB_COMMENT_API_KEY"},
Usage: "sets api key to access github api",
Destination: &settings.APIKey, Destination: &settings.APIKey,
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "base-url", Name: "base-url",
Value: "https://api.github.com/",
Usage: "api url, needs to be changed for ghe",
EnvVars: []string{"PLUGIN_BASE_URL", "GITHUB_COMMENT_BASE_URL"}, EnvVars: []string{"PLUGIN_BASE_URL", "GITHUB_COMMENT_BASE_URL"},
Usage: "sets api url; need to be changed for gh enterprise",
Value: "https://api.github.com/",
Destination: &settings.BaseURL, Destination: &settings.BaseURL,
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "key", Name: "key",
Usage: "key to assign comment",
EnvVars: []string{"PLUGIN_KEY", "GITHUB_COMMENT_KEY"}, EnvVars: []string{"PLUGIN_KEY", "GITHUB_COMMENT_KEY"},
Usage: "sets unique key to assign to comment",
Destination: &settings.Key, Destination: &settings.Key,
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "message", Name: "message",
Usage: "file or string with comment message",
EnvVars: []string{"PLUGIN_MESSAGE", "GITHUB_COMMENT_MESSAGE"}, EnvVars: []string{"PLUGIN_MESSAGE", "GITHUB_COMMENT_MESSAGE"},
Usage: "sets file or string with comment message",
Destination: &settings.Message, Destination: &settings.Message,
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "update", Name: "update",
Usage: "update an existing comment that matches the key",
EnvVars: []string{"PLUGIN_UPDATE", "GITHUB_COMMENT_UPDATE"}, EnvVars: []string{"PLUGIN_UPDATE", "GITHUB_COMMENT_UPDATE"},
Usage: "enables update of an existing comment that matches the key",
Destination: &settings.Update, Destination: &settings.Update,
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "skip-missing", Name: "skip-missing",
Value: false,
Usage: "message need to be an existing file",
EnvVars: []string{"PLUGIN_SKIP_MISSING", "GITHUB_COMMENT_SKIP_MISSING"}, EnvVars: []string{"PLUGIN_SKIP_MISSING", "GITHUB_COMMENT_SKIP_MISSING"},
Usage: "skips comment creation if the given message file does not exist",
Value: false,
Destination: &settings.SkipMissing, Destination: &settings.SkipMissing,
}, },
} }