Browse Source

docs: add parameter documentation (#69)

pull/70/head
Robert Kaussow 10 months ago committed by GitHub
parent
commit
27cba92c61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .dictionary
  2. 63
      .drone.jsonnet
  3. 333
      .drone.yml
  4. 12
      .github/settings.yml
  5. 6
      .markdownlint.yml
  6. 38
      README.md
  7. 72
      _docs/_index.md
  8. 16
      cmd/drone-github-comment/config.go

5
.dictionary

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

63
.drone.jsonnet

@ -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 = {
kind: 'pipeline',
image_pull_secrets: ['docker_config'],
@ -283,7 +338,7 @@ local PipelineNotifications = {
from_secret: 'docker_username',
},
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}',
},
when: {
@ -320,10 +375,7 @@ local PipelineNotifications = {
},
],
depends_on: [
'build-binaries',
'build-container-amd64',
'build-container-arm',
'build-container-arm64',
'docs',
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**'],
@ -337,5 +389,6 @@ local PipelineNotifications = {
PipelineBuildContainer(arch='amd64'),
PipelineBuildContainer(arch='arm64'),
PipelineBuildContainer(arch='arm'),
PipelineDocs,
PipelineNotifications,
]

333
.drone.yml

@ -1,106 +1,96 @@
---
image_pull_secrets:
- docker_config
kind: pipeline
name: test
platform:
os: linux
arch: amd64
os: linux
steps:
- name: staticcheck
image: golang:1.16
commands:
- commands:
- go run honnef.co/go/tools/cmd/staticcheck ./...
image: golang:1.16
name: staticcheck
volumes:
- name: gopath
path: /go
- name: lint
image: golang:1.16
commands:
- commands:
- go run golang.org/x/lint/golint -set_exit_status ./...
image: golang:1.16
name: lint
volumes:
- name: gopath
path: /go
- name: vet
image: golang:1.16
commands:
- commands:
- go vet ./...
image: golang:1.16
name: vet
volumes:
- name: gopath
path: /go
- name: test
image: golang:1.16
commands:
- commands:
- go test -cover ./...
image: golang:1.16
name: test
volumes:
- name: gopath
path: /go
volumes:
- name: gopath
temp: {}
image_pull_secrets:
- docker_config
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
volumes:
- name: gopath
temp: {}
---
depends_on:
- test
image_pull_secrets:
- docker_config
kind: pipeline
name: build-binaries
platform:
os: linux
arch: amd64
os: linux
steps:
- name: build
image: techknowlogick/xgo:go-1.16.x
commands:
- "[ -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/
- 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/
- ls -l /drone/src/release/
- name: executable
image: alpine
commands:
image: techknowlogick/xgo:go-1.16.x
name: build
- commands:
- $(find release/ -executable -type f | grep drone-github-comment-linux-amd64) --help
- name: compress
image: alpine
commands:
name: executable
- commands:
- apk add upx
- find release/ -maxdepth 1 -executable -type f -exec upx {} \;
- ls -lh release/
- name: checksum
image: alpine
commands:
name: compress
- commands:
- cd release/ && sha256sum * > sha256sum.txt
- name: changelog-generate
image: thegeeklab/git-chglog
commands:
image: alpine
name: checksum
- commands:
- git fetch -tq
- git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}
- name: changelog-format
image: thegeeklab/alpine-tools
commands:
- git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased
unreleased}
image: thegeeklab/git-chglog
name: changelog-generate
- commands:
- prettier CHANGELOG.md
- prettier -w CHANGELOG.md
- name: publish
image: plugins/github-release
image: thegeeklab/alpine-tools
name: changelog-format
- image: plugins/github-release
name: publish
settings:
api_key:
from_secret: github_token
@ -112,36 +102,32 @@ steps:
when:
ref:
- refs/tags/**
image_pull_secrets:
- docker_config
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
---
depends_on:
- test
---
image_pull_secrets:
- docker_config
kind: pipeline
name: build-container-amd64
platform:
os: linux
arch: amd64
os: linux
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
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
- name: dryrun
name: build
- depends_on:
- build
image: thegeeklab/drone-docker:19
name: dryrun
settings:
config:
from_secret: docker_config
@ -155,11 +141,10 @@ steps:
when:
ref:
- refs/pull/**
depends_on:
- build
- name: publish-dockerhub
- depends_on:
- dryrun
image: thegeeklab/drone-docker:19
name: publish-dockerhub
settings:
auto_tag: true
auto_tag_suffix: amd64
@ -175,11 +160,10 @@ steps:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- depends_on:
- dryrun
- name: publish-quay
image: thegeeklab/drone-docker:19
name: publish-quay
settings:
auto_tag: true
auto_tag_suffix: amd64
@ -196,38 +180,32 @@ steps:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
image_pull_secrets:
- docker_config
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
---
depends_on:
- test
---
image_pull_secrets:
- docker_config
kind: pipeline
name: build-container-arm64
platform:
os: linux
arch: arm64
os: linux
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
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
- name: dryrun
name: build
- depends_on:
- build
image: thegeeklab/drone-docker:19
name: dryrun
settings:
config:
from_secret: docker_config
@ -241,11 +219,10 @@ steps:
when:
ref:
- refs/pull/**
depends_on:
- build
- name: publish-dockerhub
- depends_on:
- dryrun
image: thegeeklab/drone-docker:19
name: publish-dockerhub
settings:
auto_tag: true
auto_tag_suffix: arm64
@ -261,11 +238,10 @@ steps:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- depends_on:
- dryrun
- name: publish-quay
image: thegeeklab/drone-docker:19
name: publish-quay
settings:
auto_tag: true
auto_tag_suffix: arm64
@ -282,38 +258,32 @@ steps:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
image_pull_secrets:
- docker_config
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
---
depends_on:
- test
---
image_pull_secrets:
- docker_config
kind: pipeline
name: build-container-arm
platform:
os: linux
arch: arm
os: linux
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
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
- name: dryrun
name: build
- depends_on:
- build
image: thegeeklab/drone-docker:19
name: dryrun
settings:
config:
from_secret: docker_config
@ -327,11 +297,10 @@ steps:
when:
ref:
- refs/pull/**
depends_on:
- build
- name: publish-dockerhub
- depends_on:
- dryrun
image: thegeeklab/drone-docker:19
name: publish-dockerhub
settings:
auto_tag: true
auto_tag_suffix: arm
@ -347,11 +316,10 @@ steps:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- depends_on:
- dryrun
- name: publish-quay
image: thegeeklab/drone-docker:19
name: publish-quay
settings:
auto_tag: true
auto_tag_suffix: arm
@ -368,32 +336,68 @@ steps:
ref:
- refs/heads/main
- refs/tags/**
depends_on:
- dryrun
image_pull_secrets:
- docker_config
trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
---
concurrency:
limit: 1
depends_on:
- test
- 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
name: notifications
platform:
os: linux
arch: amd64
os: linux
steps:
- name: manifest-dockerhub
image: plugins/manifest
- image: plugins/manifest
name: manifest-dockerhub
settings:
auto_tag: true
ignore_missing: true
@ -405,9 +409,8 @@ steps:
when:
status:
- success
- name: manifest-quay
image: plugins/manifest
- image: plugins/manifest
name: manifest-quay
settings:
auto_tag: true
ignore_missing: true
@ -419,10 +422,7 @@ steps:
when:
status:
- success
- name: pushrm-dockerhub
image: chko/docker-pushrm:1
environment:
- environment:
DOCKER_PASS:
from_secret: docker_password
DOCKER_USER:
@ -430,23 +430,23 @@ steps:
PUSHRM_FILE: README.md
PUSHRM_SHORT: Drone plugin to add comments to GitHub Issues/PRs
PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME}
image: chko/docker-pushrm:1
name: pushrm-dockerhub
when:
status:
- success
- name: pushrm-quay
image: chko/docker-pushrm:1
environment:
- environment:
APIKEY__QUAY_IO:
from_secret: quay_token
PUSHRM_FILE: README.md
PUSHRM_TARGET: quay.io/thegeeklab/${DRONE_REPO_NAME}
image: chko/docker-pushrm:1
name: pushrm-quay
when:
status:
- success
- name: matrix
image: plugins/matrix
- image: plugins/matrix
name: matrix
settings:
homeserver:
from_secret: matrix_homeserver
@ -454,17 +454,15 @@ steps:
from_secret: matrix_password
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:
from_secret: matrix_username
when:
status:
- success
- failure
image_pull_secrets:
- docker_config
trigger:
ref:
- refs/heads/main
@ -472,15 +470,8 @@ trigger:
status:
- success
- failure
depends_on:
- build-binaries
- build-container-amd64
- build-container-arm
- build-container-arm64
---
kind: signature
hmac: 53df9035380e2de0711156ba5f5df747870c7071fdd018be39041616688a9f96
hmac: c1107cd57c9386f653d0c00eb55ffc303ae691c9e99df370a71d4f8597f60235
...

12
.github/settings.yml

@ -1,6 +1,7 @@
repository:
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
private: false
@ -53,3 +54,12 @@ branches:
- continuous-integration/drone/pr
enforce_admins: 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

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

38
README.md

@ -1,6 +1,6 @@
# 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)
[![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)
[![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.
## 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
```
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).
## Contributors

72
_docs/_index.md

@ -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`)

16
cmd/drone-github-comment/config.go

@ -10,40 +10,40 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "api-key",
Usage: "api key to access github api",
EnvVars: []string{"PLUGIN_API_KEY", "GITHUB_COMMENT_API_KEY"},
Usage: "sets api key to access github api",
Destination: &settings.APIKey,
},
&cli.StringFlag{
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"},
Usage: "sets api url; need to be changed for gh enterprise",
Value: "https://api.github.com/",
Destination: &settings.BaseURL,
},
&cli.StringFlag{
Name: "key",
Usage: "key to assign comment",
EnvVars: []string{"PLUGIN_KEY", "GITHUB_COMMENT_KEY"},
Usage: "sets unique key to assign to comment",
Destination: &settings.Key,
},
&cli.StringFlag{
Name: "message",
Usage: "file or string with comment message",
EnvVars: []string{"PLUGIN_MESSAGE", "GITHUB_COMMENT_MESSAGE"},
Usage: "sets file or string with comment message",
Destination: &settings.Message,
},
&cli.BoolFlag{
Name: "update",
Usage: "update an existing comment that matches the key",
EnvVars: []string{"PLUGIN_UPDATE", "GITHUB_COMMENT_UPDATE"},
Usage: "enables update of an existing comment that matches the key",
Destination: &settings.Update,
},
&cli.BoolFlag{
Name: "skip-missing",
Value: false,
Usage: "message need to be an existing file",
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,
},
}

Loading…
Cancel
Save