mirror of
https://github.com/appleboy/drone-discord.git
synced 2026-06-13 18:51:38 +08:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 747ffca8cc | |||
| 83561d842b | |||
| 5eb8b48ec3 | |||
| fe2b53fab4 | |||
| 9fce8c8c6b | |||
| 1ab023c10d | |||
| cfd3725c9a | |||
| aecc652459 | |||
| 4ef98156ed | |||
| 7b0188f107 | |||
| 851c23f7fa | |||
| 8396f108b8 | |||
| a9f7dd6911 | |||
| 98665b9a28 | |||
| e67bb8f829 | |||
| ab201cc6f9 | |||
| fcf20615e8 | |||
| e88ca34689 | |||
| fc75470770 | |||
| 412a50abe1 | |||
| 187468f10b | |||
| d20387ae04 | |||
| 11fec702d5 | |||
| a474b187c6 |
@@ -0,0 +1,61 @@
|
||||
version: '{build}'
|
||||
image: 'Visual Studio 2017'
|
||||
platform: x64
|
||||
|
||||
max_jobs: 1
|
||||
|
||||
environment:
|
||||
GOPATH: c:\go
|
||||
docker_username:
|
||||
secure: em/TNLUXxG19O/HvbvfJuQ==
|
||||
docker_password:
|
||||
secure: Yo9FJJqihaNz5q8T4Jz8tQ==
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
install:
|
||||
- ps: |
|
||||
docker version
|
||||
go version
|
||||
go env
|
||||
|
||||
build_script:
|
||||
- ps: |
|
||||
if ( $env:APPVEYOR_REPO_TAG -eq 'false' ) {
|
||||
$version = $env:APPVEYOR_REPO_COMMIT
|
||||
} else {
|
||||
$version = $env:APPVEYOR_REPO_TAG_NAME
|
||||
}
|
||||
go build -ldflags "-X main.Version=$version" -a -o release/drone-discord.exe .
|
||||
|
||||
docker pull microsoft/nanoserver:10.0.14393.1884
|
||||
docker build -f docker/Dockerfile.windows.amd64 -t appleboy/drone-discord:windows-amd64 .
|
||||
|
||||
test_script:
|
||||
- ps: |
|
||||
docker run --rm appleboy/drone-discord:windows-amd64 --version
|
||||
|
||||
deploy_script:
|
||||
- ps: |
|
||||
$ErrorActionPreference = 'Stop';
|
||||
if ( $env:APPVEYOR_PULL_REQUEST_NUMBER ) {
|
||||
Write-Host Nothing to deploy.
|
||||
} else {
|
||||
echo $env:DOCKER_PASSWORD | docker login --username $env:DOCKER_USERNAME --password-stdin
|
||||
if ( $env:APPVEYOR_REPO_TAG -eq 'true' ) {
|
||||
$major,$minor,$patch = $env:APPVEYOR_REPO_TAG_NAME.split('.')
|
||||
docker push appleboy/drone-discord:windows-amd64
|
||||
docker tag appleboy/drone-discord:windows-amd64 appleboy/drone-discord:$major.$minor.$patch-windows-amd64
|
||||
docker push appleboy/drone-discord:$major.$minor.$patch-windows-amd64
|
||||
docker tag appleboy/drone-discord:windows-amd64 appleboy/drone-discord:$major.$minor-windows-amd64
|
||||
docker push appleboy/drone-discord:$major.$minor-windows-amd64
|
||||
docker tag appleboy/drone-discord:windows-amd64 appleboy/drone-discord:$major-windows-amd64
|
||||
docker push appleboy/drone-discord:$major-windows-amd64
|
||||
} else {
|
||||
if ( $env:APPVEYOR_REPO_BRANCH -eq 'master' ) {
|
||||
docker push appleboy/drone-discord:windows-amd64
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
-51
@@ -9,45 +9,38 @@ platform:
|
||||
steps:
|
||||
- name: vet
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- make vet
|
||||
environment:
|
||||
GO111MODULE: on
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
- name: lint
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- make lint
|
||||
environment:
|
||||
GO111MODULE: on
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
- name: misspell
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- make misspell-check
|
||||
environment:
|
||||
GO111MODULE: on
|
||||
volumes:
|
||||
- name: gopath
|
||||
path: /go
|
||||
|
||||
- name: test
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- make test
|
||||
- make coverage
|
||||
environment:
|
||||
GO111MODULE: on
|
||||
WEBHOOK_ID:
|
||||
from_secret: webhook_id
|
||||
WEBHOOK_TOKEN:
|
||||
@@ -78,12 +71,11 @@ platform:
|
||||
steps:
|
||||
- name: build-push
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-discord"
|
||||
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-discord
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
@@ -91,19 +83,18 @@ steps:
|
||||
|
||||
- name: build-tag
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-discord"
|
||||
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-discord
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
||||
- name: executable
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- ./release/linux/amd64/drone-discord --help
|
||||
|
||||
@@ -142,8 +133,8 @@ steps:
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/pull/**"
|
||||
- "refs/tags/**"
|
||||
- refs/pull/**
|
||||
- refs/tags/**
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
@@ -159,12 +150,11 @@ platform:
|
||||
steps:
|
||||
- name: build-push
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-discord"
|
||||
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-discord
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
@@ -172,19 +162,18 @@ steps:
|
||||
|
||||
- name: build-tag
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-discord"
|
||||
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-discord
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
||||
- name: executable
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- ./release/linux/arm64/drone-discord --help
|
||||
|
||||
@@ -223,8 +212,8 @@ steps:
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/pull/**"
|
||||
- "refs/tags/**"
|
||||
- refs/pull/**
|
||||
- refs/tags/**
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
@@ -240,12 +229,11 @@ platform:
|
||||
steps:
|
||||
- name: build-push
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- "go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-discord"
|
||||
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-discord
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
when:
|
||||
event:
|
||||
exclude:
|
||||
@@ -253,19 +241,18 @@ steps:
|
||||
|
||||
- name: build-tag
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- "go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-discord"
|
||||
- go build -v -ldflags '-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-discord
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
||||
- name: executable
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- ./release/linux/arm/drone-discord --help
|
||||
|
||||
@@ -304,8 +291,8 @@ steps:
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/pull/**"
|
||||
- "refs/tags/**"
|
||||
- refs/pull/**
|
||||
- refs/tags/**
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
@@ -321,11 +308,9 @@ platform:
|
||||
steps:
|
||||
- name: build-all-binary
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
image: golang:1.13
|
||||
commands:
|
||||
- make release
|
||||
environment:
|
||||
GO111MODULE: on
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
@@ -337,14 +322,14 @@ steps:
|
||||
api_key:
|
||||
from_secret: github_release_api_key
|
||||
files:
|
||||
- "dist/release/*"
|
||||
- dist/release/*
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- "refs/tags/**"
|
||||
- refs/tags/**
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
@@ -358,6 +343,16 @@ platform:
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: discord
|
||||
pull: always
|
||||
image: appleboy/drone-discord
|
||||
settings:
|
||||
message: "{{#success build.status}} ✅ Build #{{build.number}} of `{{repo.name}}` succeeded.\n\n📝 Commit by {{commit.author}} on `{{commit.branch}}`:\n``` {{commit.message}} ```\n\n🌐 {{ build.link }} {{else}} ❌ Build #{{build.number}} of `{{repo.name}}` failed.\n\n📝 Commit by {{commit.author}} on `{{commit.branch}}`:\n``` {{commit.message}} ```\n\n🌐 {{ build.link }} {{/success}}\n"
|
||||
webhook_id:
|
||||
from_secret: webhook_id
|
||||
webhook_token:
|
||||
from_secret: webhook_token
|
||||
|
||||
- name: manifest
|
||||
pull: always
|
||||
image: plugins/manifest
|
||||
@@ -369,17 +364,10 @@ steps:
|
||||
username:
|
||||
from_secret: docker_username
|
||||
|
||||
- name: microbadger
|
||||
pull: always
|
||||
image: plugins/webhook:1
|
||||
settings:
|
||||
url:
|
||||
from_secret: microbadger_url
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/tags/**"
|
||||
- refs/tags/**
|
||||
|
||||
depends_on:
|
||||
- linux-amd64
|
||||
|
||||
@@ -13,9 +13,9 @@ Webhooks are a low-effort way to post messages to channels in Discord. They do n
|
||||
The discord plugin posts build status messages to discord channel. The below pipeline configuration demonstrates simple usage:
|
||||
|
||||
```yaml
|
||||
pipeline:
|
||||
discord:
|
||||
image: appleboy/drone-discord
|
||||
- name: send notification
|
||||
image: appleboy/drone-discored
|
||||
settings:
|
||||
webhook_id: xxxxxxxxxx
|
||||
webhook_token: xxxxxxxxxx
|
||||
```
|
||||
@@ -23,9 +23,8 @@ pipeline:
|
||||
Example configuration with TTS (text-to-speech) message:
|
||||
|
||||
```diff
|
||||
pipeline:
|
||||
discord:
|
||||
image: appleboy/drone-discord
|
||||
image: appleboy/drone-discored
|
||||
settings:
|
||||
webhook_id: xxxxxxxxxx
|
||||
webhook_token: xxxxxxxxxx
|
||||
+ tts: true
|
||||
@@ -35,9 +34,8 @@ pipeline:
|
||||
Example configuration with override the default username of the webhook:
|
||||
|
||||
```diff
|
||||
pipeline:
|
||||
discord:
|
||||
image: appleboy/drone-discord
|
||||
image: appleboy/drone-discored
|
||||
settings:
|
||||
webhook_id: xxxxxxxxxx
|
||||
webhook_token: xxxxxxxxxx
|
||||
+ username: appleboy
|
||||
@@ -47,9 +45,8 @@ pipeline:
|
||||
Example configuration with override the default avatar of the webhook:
|
||||
|
||||
```diff
|
||||
pipeline:
|
||||
discord:
|
||||
image: appleboy/drone-discord
|
||||
image: appleboy/drone-discored
|
||||
settings:
|
||||
webhook_id: xxxxxxxxxx
|
||||
webhook_token: xxxxxxxxxx
|
||||
+ avatar_url: http://exampple.com/appleboy.png
|
||||
@@ -59,9 +56,8 @@ pipeline:
|
||||
Example configuration with a custom message template:
|
||||
|
||||
```diff
|
||||
pipeline:
|
||||
discord:
|
||||
image: appleboy/drone-discord
|
||||
image: appleboy/drone-discored
|
||||
settings:
|
||||
webhook_id: xxxxxxxxxx
|
||||
webhook_token: xxxxxxxxxx
|
||||
+ message: >
|
||||
@@ -75,16 +71,15 @@ pipeline:
|
||||
Example configuration using credentials from secrets:
|
||||
|
||||
```diff
|
||||
pipeline:
|
||||
discord:
|
||||
image: appleboy/drone-discord
|
||||
image: appleboy/drone-discored
|
||||
settings:
|
||||
- webhook_id: xxxxxxxxxx
|
||||
- webhook_token: xxxxxxxxxx
|
||||
+ secrets: [ discord_webhook_id, discord_webhook_token ]
|
||||
message: "Testing from drone image"
|
||||
```
|
||||
|
||||
# Secret Reference
|
||||
## Secret Reference
|
||||
|
||||
discord_webhook_id
|
||||
: discord webhook id
|
||||
@@ -92,7 +87,7 @@ discord_webhook_id
|
||||
discord_webhook_token
|
||||
: discord webhook token
|
||||
|
||||
# Parameter Reference
|
||||
## Parameter Reference
|
||||
|
||||
webhook_id
|
||||
: webhook id
|
||||
@@ -112,7 +107,7 @@ tts
|
||||
message
|
||||
: the message contents (up to 2000 characters)
|
||||
|
||||
# Template Reference
|
||||
## Template Reference
|
||||
|
||||
repo.owner
|
||||
: repository owner
|
||||
@@ -156,7 +151,7 @@ build.started
|
||||
build.finished
|
||||
: unix timestamp for build finished
|
||||
|
||||
# Template Function Reference
|
||||
## Template Function Reference
|
||||
|
||||
uppercasefirst
|
||||
: converts the first letter of a string to uppercase
|
||||
|
||||
@@ -83,7 +83,7 @@ release-build:
|
||||
@which gox > /dev/null; if [ $$? -ne 0 ]; then \
|
||||
$(GO) get -u github.com/mitchellh/gox; \
|
||||
fi
|
||||
gox -os="$(TARGETS)" -tags="$(TAGS)" -ldflags="-s -w $(LDFLAGS)" -output="$(DIST)/binaries/$(EXECUTABLE)-$(VERSION)-{{.OS}}-{{.Arch}}"
|
||||
gox -os="$(TARGETS)" -arch="amd64 386" -tags="$(TAGS)" -ldflags="-s -w $(LDFLAGS)" -output="$(DIST)/binaries/$(EXECUTABLE)-$(VERSION)-{{.OS}}-{{.Arch}}"
|
||||
|
||||
release-copy:
|
||||
$(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),cp $(file) $(DIST)/release/$(notdir $(file));)
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
<img src="images/discord-logo.png">
|
||||
|
||||
# drone-[discord](https://discordapp.com)
|
||||
|
||||

|
||||
|
||||
Drone plugin for sending message to Discord channel using Webhook.
|
||||
|
||||
[](https://godoc.org/github.com/appleboy/drone-discord)
|
||||
[](https://cloud.drone.io/appleboy/drone-discord)
|
||||
[](https://ci.appveyor.com/project/appleboy/drone-discord-bne7m)
|
||||
[](https://codecov.io/gh/appleboy/drone-discord)
|
||||
[](https://goreportcard.com/report/github.com/appleboy/drone-discord)
|
||||
[](https://hub.docker.com/r/appleboy/drone-discord/)
|
||||
[](https://microbadger.com/images/appleboy/drone-discord:linux-amd64 "Get your own image badge on microbadger.com")
|
||||
[](https://microbadger.com/images/appleboy/drone-discord:linux-amd64 "Get your own image badge on microbadger.com")
|
||||
|
||||
Webhooks are a low-effort way to post messages to channels in Discord. They do not require a bot user or authentication to use. See more [api document information](https://discordapp.com/developers/docs/resources/webhook). For the usage information and a listing of the available options please take a look at [the docs](http://plugins.drone.io/appleboy/drone-discord/).
|
||||
|
||||
@@ -18,7 +19,7 @@ Sending discord message using a binary, docker or [Drone CI](http://docs.drone.i
|
||||
## Features
|
||||
|
||||
* [x] Send Multiple Messages
|
||||
* [x] Send Multiple Files
|
||||
* [x] Send Multiple Files
|
||||
|
||||
## Build or Download a binary
|
||||
|
||||
@@ -30,52 +31,29 @@ The pre-compiled binaries can be downloaded from [release page](https://github.c
|
||||
|
||||
With `Go` installed
|
||||
|
||||
```sh
|
||||
go get -u -v github.com/appleboy/drone-discord
|
||||
```
|
||||
$ go get -u -v github.com/appleboy/drone-discord
|
||||
```
|
||||
|
||||
or build the binary with the following command:
|
||||
|
||||
```
|
||||
$ export GOOS=linux
|
||||
$ export GOARCH=amd64
|
||||
$ export CGO_ENABLED=0
|
||||
$ export GO111MODULE=on
|
||||
```sh
|
||||
export GOOS=linux
|
||||
export GOARCH=amd64
|
||||
export CGO_ENABLED=0
|
||||
export GO111MODULE=on
|
||||
|
||||
$ go test -cover ./...
|
||||
go test -cover ./...
|
||||
|
||||
$ go build -v -a -tags netgo -o release/linux/amd64/drone-discord .
|
||||
```
|
||||
|
||||
## Docker
|
||||
|
||||
Build the docker image with the following commands:
|
||||
|
||||
```
|
||||
$ make docker
|
||||
```
|
||||
|
||||
Please note incorrectly building the image for the correct x64 linux and with
|
||||
CGO disabled will result in an error when running the Docker image:
|
||||
|
||||
```
|
||||
docker: Error response from daemon: Container command
|
||||
'/bin/drone-discord' not found or does not exist..
|
||||
go build -v -a -tags netgo -o release/linux/amd64/drone-discord
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
There are three ways to send notification.
|
||||
|
||||
* [usage from binary](#usage-from-binary)
|
||||
* [usage from docker](#usage-from-docker)
|
||||
* [usage from drone ci](#usage-from-drone-ci)
|
||||
|
||||
<a name="usage-from-binary"></a>
|
||||
### Usage from binary
|
||||
|
||||
#### Send Notification
|
||||
|
||||
```bash
|
||||
drone-discord \
|
||||
--webhook-id xxxx \
|
||||
@@ -83,11 +61,8 @@ drone-discord \
|
||||
--message "Test Message"
|
||||
```
|
||||
|
||||
<a name="usage-from-docker"></a>
|
||||
### Usage from docker
|
||||
|
||||
#### Send Notification
|
||||
|
||||
```bash
|
||||
docker run --rm \
|
||||
-e WEBHOOK_ID=xxxxxxx \
|
||||
@@ -100,14 +75,13 @@ docker run --rm \
|
||||
appleboy/drone-discord
|
||||
```
|
||||
|
||||
<a name="usage-from-drone-ci"></a>
|
||||
### Usage from drone ci
|
||||
|
||||
#### Send Notification
|
||||
|
||||
Execute from the working directory:
|
||||
|
||||
```bash
|
||||
```sh
|
||||
docker run --rm \
|
||||
-e WEBHOOK_ID=xxxxxxx \
|
||||
-e WEBHOOK_TOKEN=xxxxxxx \
|
||||
@@ -139,6 +113,6 @@ You can get more [information](DOCS.md) about how to use this plugin in drone.
|
||||
|
||||
Test the package with the following command:
|
||||
|
||||
```
|
||||
$ make test
|
||||
```sh
|
||||
make test
|
||||
```
|
||||
|
||||
@@ -5,6 +5,6 @@ LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
||||
org.label-schema.vendor="Bo-Yi Wu" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/linux/amd64/drone-discord /bin/
|
||||
COPY release/linux/amd64/drone-discord /bin/
|
||||
|
||||
ENTRYPOINT ["/bin/drone-discord"]
|
||||
|
||||
@@ -5,6 +5,6 @@ LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
||||
org.label-schema.vendor="Bo-Yi Wu" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/linux/arm/drone-discord /bin/
|
||||
COPY release/linux/arm/drone-discord /bin/
|
||||
|
||||
ENTRYPOINT ["/bin/drone-discord"]
|
||||
|
||||
@@ -5,6 +5,6 @@ LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
||||
org.label-schema.vendor="Bo-Yi Wu" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/linux/arm64/drone-discord /bin/
|
||||
COPY release/linux/arm64/drone-discord /bin/
|
||||
|
||||
ENTRYPOINT ["/bin/drone-discord"]
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
FROM plugins/base:windows-amd64
|
||||
FROM microsoft/nanoserver:10.0.14393.1884
|
||||
|
||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
||||
org.label-schema.name="Drone Discord" \
|
||||
org.label-schema.vendor="Bo-Yi Wu" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/drone-discord.exe /drone-discord.exe
|
||||
ENTRYPOINT [ "\\drone-discord.exe" ]
|
||||
COPY release/drone-discord.exe C:/bin/drone-discord.exe
|
||||
|
||||
ENTRYPOINT [ "C:\\bin\\drone-discord.exe" ]
|
||||
@@ -1,4 +1,4 @@
|
||||
image: appleboy/drone-discord:{{#if build.tag}}{{trimPrefix build.tag "v"}}{{else}}latest{{/if}}
|
||||
image: appleboy/drone-discord:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
@@ -7,18 +7,18 @@ tags:
|
||||
{{/if}}
|
||||
manifests:
|
||||
-
|
||||
image: appleboy/drone-discord:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-amd64
|
||||
image: appleboy/drone-discord:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: appleboy/drone-discord:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm64
|
||||
image: appleboy/drone-discord:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||
platform:
|
||||
architecture: arm64
|
||||
os: linux
|
||||
variant: v8
|
||||
-
|
||||
image: appleboy/drone-discord:{{#if build.tag}}{{trimPrefix build.tag "v"}}-{{/if}}linux-arm
|
||||
image: appleboy/drone-discord:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||
platform:
|
||||
architecture: arm
|
||||
os: linux
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
module github.com/appleboy/drone-discord
|
||||
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/appleboy/drone-facebook v0.0.0-20170430101616-fdda56ebba0f
|
||||
github.com/aymerick/raymond v0.0.0-20161209220724-72acac220747 // indirect
|
||||
github.com/davecgh/go-spew v1.1.0 // indirect
|
||||
github.com/joho/godotenv v0.0.0-20170328200154-325433c502d4
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/testify v0.0.0-20170601210322-f6abca593680
|
||||
github.com/urfave/cli v0.0.0-20170506042529-d70f47eeca3a
|
||||
gopkg.in/yaml.v2 v2.2.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/drone/drone-template-lib v1.0.0
|
||||
github.com/joho/godotenv v1.3.0
|
||||
github.com/stretchr/testify v1.4.0
|
||||
github.com/urfave/cli v1.22.1
|
||||
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 // indirect
|
||||
)
|
||||
|
||||
@@ -1,17 +1,52 @@
|
||||
github.com/appleboy/drone-facebook v0.0.0-20170430101616-fdda56ebba0f h1:X+DQ0ayEB/dcUp/YcsKzKcgdowjmUUInoRCYhtK1yg0=
|
||||
github.com/appleboy/drone-facebook v0.0.0-20170430101616-fdda56ebba0f/go.mod h1:5PxqvgIcQy+Je2Rde2tbxGUG9/emkCHkFqZg/8vf4ZA=
|
||||
github.com/aymerick/raymond v0.0.0-20161209220724-72acac220747 h1:gu88ZN3sXG5+1mH0W4Ty00jzHA044ND3ogxmJNN6Rik=
|
||||
github.com/aymerick/raymond v0.0.0-20161209220724-72acac220747/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
|
||||
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
||||
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
|
||||
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
||||
github.com/Masterminds/sprig v2.18.0+incompatible h1:QoGhlbC6pter1jxKnjMFxT8EqsLuDE6FEcNbWEpw+lI=
|
||||
github.com/Masterminds/sprig v2.18.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
|
||||
github.com/aymerick/raymond v2.0.2+incompatible h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0=
|
||||
github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
|
||||
github.com/bouk/monkey v1.0.0 h1:k6z8fLlPhETfn5l9rlWVE7Q6B23DoaqosTdArvNQRdc=
|
||||
github.com/bouk/monkey v1.0.0/go.mod h1:PG/63f4XEUlVyW1ttIeOJmJhhe1+t9EC/je3eTjvFhE=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/joho/godotenv v0.0.0-20170328200154-325433c502d4 h1:4efwqN/95XpF2pyttkH2f288+TcG0jFQUk0avks7zes=
|
||||
github.com/joho/godotenv v0.0.0-20170328200154-325433c502d4/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/drone/drone-template-lib v1.0.0 h1:PNBBfUhifRnrPCoWBlTitk3jipXdv8u8WLbIf7h7j00=
|
||||
github.com/drone/drone-template-lib v1.0.0/go.mod h1:Hqy1tgqPH5mtbFOZmow19l4jOkZvp+WZ00cB4W3MJhg=
|
||||
github.com/google/uuid v1.1.0 h1:Jf4mxPC/ziBnoPIdpQdPJ9OeiomAUHLvxmPRSPH9m4s=
|
||||
github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0=
|
||||
github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4=
|
||||
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
|
||||
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v0.0.0-20170601210322-f6abca593680 h1:k3Cv7ttquofwySV/QIpSg4f2UYl/sPXAoTKIxO9CNGc=
|
||||
github.com/stretchr/testify v0.0.0-20170601210322-f6abca593680/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/urfave/cli v0.0.0-20170506042529-d70f47eeca3a h1:QCKpTIKfYPSx19VYrRHtsbShQVfIFzBFe3pO/wBUOc8=
|
||||
github.com/urfave/cli v0.0.0-20170506042529-d70f47eeca3a/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/tkuchiki/faketime v0.0.0-20170607100027-a4500a4f4643 h1:ii/sHfgFMByozryLeiDmn1ClZ/Pena4NgpJ4P7UuX9o=
|
||||
github.com/tkuchiki/faketime v0.0.0-20170607100027-a4500a4f4643/go.mod h1:RXY/TXAwGGL36IKDjrHFMcjpUrEiyWSEtLhFPw3UWF0=
|
||||
github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 h1:p/H982KKEjUnLJkM3tt/LemDnOc1GiZL5FCVlORJ5zo=
|
||||
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
|
||||
@@ -32,47 +32,47 @@ func main() {
|
||||
cli.StringFlag{
|
||||
Name: "webhook-id",
|
||||
Usage: "discord webhook id",
|
||||
EnvVar: "PLUGIN_WEBHOOK_ID,WEBHOOK_ID,DISCORD_WEBHOOK_ID",
|
||||
EnvVar: "PLUGIN_WEBHOOK_ID,WEBHOOK_ID,DISCORD_WEBHOOK_ID,INPUT_WEBHOOK_ID",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "webhook-token",
|
||||
Usage: "discord webhook token",
|
||||
EnvVar: "PLUGIN_WEBHOOK_TOKEN,WEBHOOK_TOKEN,DISCORD_WEBHOOK_TOKEN",
|
||||
EnvVar: "PLUGIN_WEBHOOK_TOKEN,WEBHOOK_TOKEN,DISCORD_WEBHOOK_TOKEN,INPUT_WEBHOOK_TOKEN",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "message",
|
||||
Usage: "the message contents (up to 2000 characters)",
|
||||
EnvVar: "PLUGIN_MESSAGE,DISCORD_MESSAGE,MESSAGE",
|
||||
EnvVar: "PLUGIN_MESSAGE,DISCORD_MESSAGE,MESSAGE,INPUT_MESSAGE",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "file",
|
||||
Usage: "the contents of the file being sent",
|
||||
EnvVar: "PLUGIN_FILE,DISCORD_FILE,FILE",
|
||||
EnvVar: "PLUGIN_FILE,DISCORD_FILE,FILE,INPUT_FILE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "color",
|
||||
Usage: "color code of the embed",
|
||||
EnvVar: "PLUGIN_COLOR,COLOR",
|
||||
EnvVar: "PLUGIN_COLOR,COLOR,INPUT_COLOR",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "wait",
|
||||
Usage: "waits for server confirmation of message send before response, and returns the created message body",
|
||||
EnvVar: "PLUGIN_WAIT,WAIT",
|
||||
EnvVar: "PLUGIN_WAIT,WAIT,INPUT_WAIT",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "tts",
|
||||
Usage: "true if this is a TTS message",
|
||||
EnvVar: "PLUGIN_TTS,TTS",
|
||||
EnvVar: "PLUGIN_TTS,TTS,INPUT_TTS",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "username",
|
||||
Usage: "override the default username of the webhook",
|
||||
EnvVar: "PLUGIN_USERNAME,USERNAME",
|
||||
EnvVar: "PLUGIN_USERNAME,USERNAME,INPUT_USERNAME",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "avatar-url",
|
||||
Usage: "override the default avatar of the webhook",
|
||||
EnvVar: "PLUGIN_AVATAR_URL,AVATAR_URL",
|
||||
EnvVar: "PLUGIN_AVATAR_URL,AVATAR_URL,INPUT_AVATAR_URL",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "drone",
|
||||
@@ -110,6 +110,11 @@ func main() {
|
||||
Usage: "git commit branch",
|
||||
EnvVar: "DRONE_COMMIT_BRANCH",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "commit.link",
|
||||
Usage: "git commit link",
|
||||
EnvVar: "DRONE_COMMIT_LINK",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "commit.author",
|
||||
Usage: "git author name",
|
||||
@@ -157,6 +162,11 @@ func main() {
|
||||
Usage: "build tag",
|
||||
EnvVar: "DRONE_TAG",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "pull.request",
|
||||
Usage: "pull request",
|
||||
EnvVar: "DRONE_PULL_REQUEST",
|
||||
},
|
||||
cli.Float64Flag{
|
||||
Name: "job.started",
|
||||
Usage: "job started",
|
||||
@@ -201,6 +211,11 @@ func main() {
|
||||
Usage: "The GitHub workspace path. Value: /github/workspace.",
|
||||
EnvVar: "GITHUB_WORKSPACE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "deploy.to",
|
||||
Usage: "Provides the target deployment environment for the running build. This value is only available to promotion and rollback pipelines.",
|
||||
EnvVar: "DRONE_DEPLOY_TO",
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
@@ -226,21 +241,26 @@ func run(c *cli.Context) error {
|
||||
Namespace: c.String("repo.namespace"),
|
||||
Name: c.String("repo.name"),
|
||||
},
|
||||
Commit: Commit{
|
||||
Sha: c.String("commit.sha"),
|
||||
Ref: c.String("commit.ref"),
|
||||
Branch: c.String("commit.branch"),
|
||||
Link: c.String("commit.link"),
|
||||
Author: c.String("commit.author"),
|
||||
Email: c.String("commit.author.email"),
|
||||
Avatar: c.String("commit.author.avatar"),
|
||||
Message: c.String("commit.message"),
|
||||
},
|
||||
Build: Build{
|
||||
Tag: c.String("build.tag"),
|
||||
Number: c.Int("build.number"),
|
||||
Event: c.String("build.event"),
|
||||
Status: c.String("build.status"),
|
||||
Commit: c.String("commit.sha"),
|
||||
RefSpec: c.String("commit.refspec"),
|
||||
Branch: c.String("commit.branch"),
|
||||
Author: c.String("commit.author"),
|
||||
Email: c.String("commit.author.email"),
|
||||
Avatar: c.String("commit.author.avatar"),
|
||||
Message: c.String("commit.message"),
|
||||
Link: c.String("build.link"),
|
||||
Started: c.Float64("job.started"),
|
||||
Finished: c.Float64("job.finished"),
|
||||
PR: c.String("pull.request"),
|
||||
DeployTo: c.String("deploy.to"),
|
||||
},
|
||||
Config: Config{
|
||||
WebhookID: c.String("webhook-id"),
|
||||
|
||||
+18
-31
@@ -9,11 +9,8 @@
|
||||
steps: [
|
||||
{
|
||||
name: 'vet',
|
||||
image: 'golang:1.11',
|
||||
image: 'golang:1.13',
|
||||
pull: 'always',
|
||||
environment: {
|
||||
GO111MODULE: 'on',
|
||||
},
|
||||
commands: [
|
||||
'make vet',
|
||||
],
|
||||
@@ -26,11 +23,8 @@
|
||||
},
|
||||
{
|
||||
name: 'lint',
|
||||
image: 'golang:1.11',
|
||||
image: 'golang:1.13',
|
||||
pull: 'always',
|
||||
environment: {
|
||||
GO111MODULE: 'on',
|
||||
},
|
||||
commands: [
|
||||
'make lint',
|
||||
],
|
||||
@@ -43,11 +37,8 @@
|
||||
},
|
||||
{
|
||||
name: 'misspell',
|
||||
image: 'golang:1.11',
|
||||
image: 'golang:1.13',
|
||||
pull: 'always',
|
||||
environment: {
|
||||
GO111MODULE: 'on',
|
||||
},
|
||||
commands: [
|
||||
'make misspell-check',
|
||||
],
|
||||
@@ -60,10 +51,9 @@
|
||||
},
|
||||
{
|
||||
name: 'test',
|
||||
image: 'golang:1.11',
|
||||
image: 'golang:1.13',
|
||||
pull: 'always',
|
||||
environment: {
|
||||
GO111MODULE: 'on',
|
||||
WEBHOOK_ID: { 'from_secret': 'webhook_id' },
|
||||
WEBHOOK_TOKEN: { 'from_secret': 'webhook_token' },
|
||||
},
|
||||
@@ -105,11 +95,10 @@
|
||||
steps: [
|
||||
{
|
||||
name: 'build-push',
|
||||
image: 'golang:1.11',
|
||||
image: 'golang:1.13',
|
||||
pull: 'always',
|
||||
environment: {
|
||||
CGO_ENABLED: '0',
|
||||
GO111MODULE: 'on',
|
||||
},
|
||||
commands: [
|
||||
'go build -v -ldflags \'-X main.build=${DRONE_BUILD_NUMBER}\' -a -o release/' + os + '/' + arch + '/' + name,
|
||||
@@ -122,11 +111,10 @@
|
||||
},
|
||||
{
|
||||
name: 'build-tag',
|
||||
image: 'golang:1.11',
|
||||
image: 'golang:1.13',
|
||||
pull: 'always',
|
||||
environment: {
|
||||
CGO_ENABLED: '0',
|
||||
GO111MODULE: 'on',
|
||||
},
|
||||
commands: [
|
||||
'go build -v -ldflags \'-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\' -a -o release/' + os + '/' + arch + '/' + name,
|
||||
@@ -137,7 +125,7 @@
|
||||
},
|
||||
{
|
||||
name: 'executable',
|
||||
image: 'golang:1.11',
|
||||
image: 'golang:1.13',
|
||||
pull: 'always',
|
||||
commands: [
|
||||
'./release/' + os + '/' + arch + '/' + name + ' --help',
|
||||
@@ -202,11 +190,8 @@
|
||||
steps: [
|
||||
{
|
||||
name: 'build-all-binary',
|
||||
image: 'golang:1.11',
|
||||
image: 'golang:1.13',
|
||||
pull: 'always',
|
||||
environment: {
|
||||
GO111MODULE: 'on',
|
||||
},
|
||||
commands: [
|
||||
'make release'
|
||||
],
|
||||
@@ -245,6 +230,16 @@
|
||||
arch: arch,
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: 'discord',
|
||||
image: 'appleboy/drone-discord',
|
||||
pull: 'always',
|
||||
settings: {
|
||||
webhook_id: { from_secret: 'webhook_id' },
|
||||
webhook_token: { from_secret: 'webhook_token' },
|
||||
message: '{{#success build.status}} ✅ Build #{{build.number}} of `{{repo.name}}` succeeded.\n\n📝 Commit by {{commit.author}} on `{{commit.branch}}`:\n``` {{commit.message}} ```\n\n🌐 {{ build.link }} {{else}} ❌ Build #{{build.number}} of `{{repo.name}}` failed.\n\n📝 Commit by {{commit.author}} on `{{commit.branch}}`:\n``` {{commit.message}} ```\n\n🌐 {{ build.link }} {{/success}}\n',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'manifest',
|
||||
image: 'plugins/manifest',
|
||||
@@ -256,14 +251,6 @@
|
||||
ignore_missing: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'microbadger',
|
||||
image: 'plugins/webhook:1',
|
||||
pull: 'always',
|
||||
settings: {
|
||||
url: { 'from_secret': 'microbadger_url' },
|
||||
},
|
||||
},
|
||||
],
|
||||
depends_on: depends_on,
|
||||
trigger: {
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/appleboy/drone-facebook/template"
|
||||
"github.com/drone/drone-template-lib/template"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -33,29 +33,36 @@ type (
|
||||
EventPath string
|
||||
}
|
||||
|
||||
// Repo information
|
||||
// Repo information.
|
||||
Repo struct {
|
||||
FullName string
|
||||
Namespace string
|
||||
Name string
|
||||
}
|
||||
|
||||
// Build information
|
||||
// Commit information.
|
||||
Commit struct {
|
||||
Sha string
|
||||
Ref string
|
||||
Branch string
|
||||
Link string
|
||||
Author string
|
||||
Avatar string
|
||||
Email string
|
||||
Message string
|
||||
}
|
||||
|
||||
// Build information.
|
||||
Build struct {
|
||||
Tag string
|
||||
Event string
|
||||
Number int
|
||||
Commit string
|
||||
RefSpec string
|
||||
Branch string
|
||||
Author string
|
||||
Avatar string
|
||||
Message string
|
||||
Email string
|
||||
Status string
|
||||
Link string
|
||||
Started float64
|
||||
Finished float64
|
||||
PR string
|
||||
DeployTo string
|
||||
}
|
||||
|
||||
// Config for the plugin.
|
||||
@@ -116,10 +123,16 @@ type (
|
||||
Build Build
|
||||
Config Config
|
||||
Payload Payload
|
||||
Commit Commit
|
||||
}
|
||||
)
|
||||
|
||||
func templateMessage(t string, plugin Plugin) (string, error) {
|
||||
return template.RenderTrim(t, plugin)
|
||||
}
|
||||
|
||||
// Creates a new file upload http request with optional extra params
|
||||
// https://matt.aimonetti.net/posts/2013/07/01/golang-multipart-file-upload-example/
|
||||
func newfileUploadRequest(uri string, params map[string]string, paramName, path string) (*http.Request, error) {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
@@ -165,7 +178,7 @@ func (p *Plugin) Exec() error {
|
||||
|
||||
if len(p.Config.Message) > 0 {
|
||||
for _, m := range p.Config.Message {
|
||||
txt, err := template.RenderTrim(m, p)
|
||||
txt, err := templateMessage(m, *p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -191,6 +204,9 @@ func (p *Plugin) Exec() error {
|
||||
}
|
||||
|
||||
for _, f := range p.Config.File {
|
||||
if f == "" {
|
||||
continue
|
||||
}
|
||||
err := p.SendFile(f)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -282,27 +298,27 @@ func (p *Plugin) Template() EmbedObject {
|
||||
description := ""
|
||||
switch p.Build.Event {
|
||||
case "push":
|
||||
description = fmt.Sprintf("%s pushed to %s", p.Build.Author, p.Build.Branch)
|
||||
description = fmt.Sprintf("%s pushed to %s", p.Commit.Author, p.Commit.Branch)
|
||||
case "pull_request":
|
||||
branch := ""
|
||||
if p.Build.RefSpec != "" {
|
||||
branch = p.Build.RefSpec
|
||||
if p.Commit.Ref != "" {
|
||||
branch = p.Commit.Ref
|
||||
} else {
|
||||
branch = p.Build.Branch
|
||||
branch = p.Commit.Branch
|
||||
}
|
||||
description = fmt.Sprintf("%s updated pull request %s", p.Build.Author, branch)
|
||||
description = fmt.Sprintf("%s updated pull request %s", p.Commit.Author, branch)
|
||||
case "tag":
|
||||
description = fmt.Sprintf("%s pushed tag %s", p.Build.Author, p.Build.Branch)
|
||||
description = fmt.Sprintf("%s pushed tag %s", p.Commit.Author, p.Commit.Branch)
|
||||
}
|
||||
|
||||
return EmbedObject{
|
||||
Title: p.Build.Message,
|
||||
Title: p.Commit.Message,
|
||||
Description: description,
|
||||
URL: p.Build.Link,
|
||||
Color: p.Color(),
|
||||
Author: EmbedAuthorObject{
|
||||
Name: p.Build.Author,
|
||||
IconURL: p.Build.Avatar,
|
||||
Name: p.Commit.Author,
|
||||
IconURL: p.Commit.Avatar,
|
||||
},
|
||||
Footer: EmbedFooterObject{
|
||||
Text: DroneDesc,
|
||||
|
||||
+10
-9
@@ -22,17 +22,18 @@ func TestTemplate(t *testing.T) {
|
||||
Name: "go-hello",
|
||||
Namespace: "appleboy",
|
||||
},
|
||||
Build: Build{
|
||||
Number: 101,
|
||||
Status: "success",
|
||||
Link: "https://github.com/appleboy/go-hello",
|
||||
Commit: Commit{
|
||||
Author: "appleboy",
|
||||
Branch: "master",
|
||||
Event: "tag",
|
||||
Message: "update by drone discord plugin. \r\n update by drone discord plugin.",
|
||||
Commit: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||
Avatar: "https://avatars0.githubusercontent.com/u/21979?v=3&s=100",
|
||||
},
|
||||
Build: Build{
|
||||
Number: 101,
|
||||
Status: "success",
|
||||
Link: "https://github.com/appleboy/go-hello",
|
||||
Event: "tag",
|
||||
},
|
||||
|
||||
Config: Config{
|
||||
WebhookID: os.Getenv("WEBHOOK_ID"),
|
||||
@@ -69,7 +70,7 @@ func TestTemplate(t *testing.T) {
|
||||
|
||||
// send success embed message
|
||||
plugin.Build.Status = "failure"
|
||||
plugin.Build.Message = "send failure embed message"
|
||||
plugin.Commit.Message = "send failure embed message"
|
||||
plugin.Clear()
|
||||
err = plugin.Exec()
|
||||
assert.Nil(t, err)
|
||||
@@ -77,14 +78,14 @@ func TestTemplate(t *testing.T) {
|
||||
|
||||
// send default embed message
|
||||
plugin.Build.Status = "test"
|
||||
plugin.Build.Message = "send default embed message"
|
||||
plugin.Commit.Message = "send default embed message"
|
||||
plugin.Clear()
|
||||
err = plugin.Exec()
|
||||
assert.Nil(t, err)
|
||||
|
||||
//change color for embed message
|
||||
plugin.Config.Color = "#4842f4"
|
||||
plugin.Build.Message = "Change embed color to #4842f4"
|
||||
plugin.Commit.Message = "Change embed color to #4842f4"
|
||||
plugin.Clear()
|
||||
err = plugin.Exec()
|
||||
assert.Nil(t, err)
|
||||
|
||||
Reference in New Issue
Block a user