mirror of
https://github.com/appleboy/drone-telegram.git
synced 2026-06-04 18:23:45 +08:00
Compare commits
75 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cd7b8b4656 | |||
| 530ced4f2a | |||
| 072876987d | |||
| caaf39fc08 | |||
| d746084872 | |||
| 6379123ca3 | |||
| cff7d4e183 | |||
| 7007692d2e | |||
| 23f0958c87 | |||
| c8c37942c1 | |||
| a7daa0df80 | |||
| f3ace6f519 | |||
| 4de983b4ef | |||
| b4a51bd6b6 | |||
| 30b9c501ff | |||
| cbae1a3737 | |||
| 0bc6220388 | |||
| 8587a97ab1 | |||
| 893f3c30bf | |||
| 1f66667a65 | |||
| 47c90ae600 | |||
| 65d453bece | |||
| 45cfcd8bb1 | |||
| a82484f5d7 | |||
| 4b48840e98 | |||
| 3660832535 | |||
| 104ffc4fe7 | |||
| 80e7a36e5e | |||
| 6fdd0872fb | |||
| d0cc2a2774 | |||
| 69c7f9efd1 | |||
| 9d6dcccab5 | |||
| 58c63ee76a | |||
| ce010e6672 | |||
| 3b9ad40520 | |||
| f103b43735 | |||
| 361d59920c | |||
| a77434ffeb | |||
| a8e9c83c55 | |||
| 3c91807166 | |||
| 8239f0f8b1 | |||
| de446823b7 | |||
| d8db8b8eea | |||
| 49d1464e69 | |||
| 99974ef0e7 | |||
| dc775b15ea | |||
| 571987a1f0 | |||
| 92b96294c4 | |||
| 81d4eb4d8f | |||
| 8ca83919d2 | |||
| ab44454733 | |||
| 2dfbc98fdd | |||
| 24f5558e9e | |||
| ca270b33c8 | |||
| 882afee629 | |||
| d5d27734b0 | |||
| e0f4e9a9e4 | |||
| d6c3514a66 | |||
| 6dbb4b1735 | |||
| a91d132e3f | |||
| 91cd4c1be5 | |||
| 7abe52fd7d | |||
| 80f55d4df9 | |||
| 9cab2d0e2b | |||
| d133c8b87c | |||
| 390d4f4d5f | |||
| 792e5b5eab | |||
| 392621b9a5 | |||
| dc17cf7288 | |||
| 737043aa8d | |||
| 4c016c904c | |||
| f021aab825 | |||
| 47352c6cca | |||
| ee0358892d | |||
| 153fe2cb01 |
@@ -1,63 +0,0 @@
|
|||||||
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==
|
|
||||||
GO111MODULE: on
|
|
||||||
|
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
|
|
||||||
install:
|
|
||||||
- ps: |
|
|
||||||
docker version
|
|
||||||
go version
|
|
||||||
go env
|
|
||||||
|
|
||||||
build_script:
|
|
||||||
- ps: |
|
|
||||||
go mod download
|
|
||||||
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-telegram.exe .
|
|
||||||
|
|
||||||
docker pull microsoft/nanoserver:10.0.14393.1884
|
|
||||||
docker build -f docker/Dockerfile.windows.amd64 -t appleboy/drone-telegram:windows-amd64 .
|
|
||||||
|
|
||||||
test_script:
|
|
||||||
- ps: |
|
|
||||||
docker run --rm appleboy/drone-telegram: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-telegram:windows-amd64
|
|
||||||
docker tag appleboy/drone-telegram:windows-amd64 appleboy/drone-telegram:$major.$minor.$patch-windows-amd64
|
|
||||||
docker push appleboy/drone-telegram:$major.$minor.$patch-windows-amd64
|
|
||||||
docker tag appleboy/drone-telegram:windows-amd64 appleboy/drone-telegram:$major.$minor-windows-amd64
|
|
||||||
docker push appleboy/drone-telegram:$major.$minor-windows-amd64
|
|
||||||
docker tag appleboy/drone-telegram:windows-amd64 appleboy/drone-telegram:$major-windows-amd64
|
|
||||||
docker push appleboy/drone-telegram:$major-windows-amd64
|
|
||||||
} else {
|
|
||||||
if ( $env:APPVEYOR_REPO_BRANCH -eq 'master' ) {
|
|
||||||
docker push appleboy/drone-telegram:windows-amd64
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
local pipeline = import 'pipeline.libsonnet';
|
|
||||||
local name = 'drone-telegram';
|
|
||||||
|
|
||||||
[
|
|
||||||
pipeline.test,
|
|
||||||
pipeline.build(name, 'linux', 'amd64'),
|
|
||||||
pipeline.build(name, 'linux', 'arm64'),
|
|
||||||
pipeline.build(name, 'linux', 'arm'),
|
|
||||||
pipeline.release,
|
|
||||||
pipeline.notifications(depends_on=[
|
|
||||||
'linux-amd64',
|
|
||||||
'linux-arm64',
|
|
||||||
'linux-arm',
|
|
||||||
'release-binary',
|
|
||||||
]),
|
|
||||||
pipeline.signature('9a4dcc3659b6f2cb98486e40e4cb0c16d6fc19ad783d3bca13d30c476daf8213'),
|
|
||||||
]
|
|
||||||
-382
@@ -1,382 +0,0 @@
|
|||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: testing
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: vet
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- make vet
|
|
||||||
volumes:
|
|
||||||
- name: gopath
|
|
||||||
path: /go
|
|
||||||
|
|
||||||
- name: lint
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- make lint
|
|
||||||
volumes:
|
|
||||||
- name: gopath
|
|
||||||
path: /go
|
|
||||||
|
|
||||||
- name: misspell
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- make misspell-check
|
|
||||||
volumes:
|
|
||||||
- name: gopath
|
|
||||||
path: /go
|
|
||||||
|
|
||||||
- name: test
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- make test
|
|
||||||
- make coverage
|
|
||||||
environment:
|
|
||||||
TELEGRAM_TO:
|
|
||||||
from_secret: telegram_to
|
|
||||||
TELEGRAM_TOKEN:
|
|
||||||
from_secret: telegram_token
|
|
||||||
volumes:
|
|
||||||
- name: gopath
|
|
||||||
path: /go
|
|
||||||
|
|
||||||
- name: codecov
|
|
||||||
pull: always
|
|
||||||
image: robertstettner/drone-codecov
|
|
||||||
settings:
|
|
||||||
token:
|
|
||||||
from_secret: codecov_token
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: gopath
|
|
||||||
temp: {}
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: linux-amd64
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build-push
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/amd64/drone-telegram
|
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: build-tag
|
|
||||||
pull: always
|
|
||||||
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-telegram
|
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: executable
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- ./release/linux/amd64/drone-telegram --help
|
|
||||||
|
|
||||||
- name: dryrun
|
|
||||||
pull: always
|
|
||||||
image: plugins/docker:linux-amd64
|
|
||||||
settings:
|
|
||||||
cache_from: appleboy/drone-telegram
|
|
||||||
dockerfile: docker/Dockerfile.linux.amd64
|
|
||||||
dry_run: true
|
|
||||||
repo: appleboy/drone-telegram
|
|
||||||
tags: linux-amd64
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
- name: publish
|
|
||||||
pull: always
|
|
||||||
image: plugins/docker:linux-amd64
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: linux-amd64
|
|
||||||
cache_from: appleboy/drone-telegram
|
|
||||||
daemon_off: false
|
|
||||||
dockerfile: docker/Dockerfile.linux.amd64
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: appleboy/drone-telegram
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- refs/pull/**
|
|
||||||
- refs/tags/**
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- testing
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: linux-arm64
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: arm64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build-push
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm64/drone-telegram
|
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: build-tag
|
|
||||||
pull: always
|
|
||||||
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-telegram
|
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: executable
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- ./release/linux/arm64/drone-telegram --help
|
|
||||||
|
|
||||||
- name: dryrun
|
|
||||||
pull: always
|
|
||||||
image: plugins/docker:linux-arm64
|
|
||||||
settings:
|
|
||||||
cache_from: appleboy/drone-telegram
|
|
||||||
dockerfile: docker/Dockerfile.linux.arm64
|
|
||||||
dry_run: true
|
|
||||||
repo: appleboy/drone-telegram
|
|
||||||
tags: linux-arm64
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
- name: publish
|
|
||||||
pull: always
|
|
||||||
image: plugins/docker:linux-arm64
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: linux-arm64
|
|
||||||
cache_from: appleboy/drone-telegram
|
|
||||||
daemon_off: false
|
|
||||||
dockerfile: docker/Dockerfile.linux.arm64
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: appleboy/drone-telegram
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- refs/pull/**
|
|
||||||
- refs/tags/**
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- testing
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: linux-arm
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: arm
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build-push
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- go build -v -ldflags '-X main.build=${DRONE_BUILD_NUMBER}' -a -o release/linux/arm/drone-telegram
|
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: build-tag
|
|
||||||
pull: always
|
|
||||||
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-telegram
|
|
||||||
environment:
|
|
||||||
CGO_ENABLED: 0
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: executable
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- ./release/linux/arm/drone-telegram --help
|
|
||||||
|
|
||||||
- name: dryrun
|
|
||||||
pull: always
|
|
||||||
image: plugins/docker:linux-arm
|
|
||||||
settings:
|
|
||||||
cache_from: appleboy/drone-telegram
|
|
||||||
dockerfile: docker/Dockerfile.linux.arm
|
|
||||||
dry_run: true
|
|
||||||
repo: appleboy/drone-telegram
|
|
||||||
tags: linux-arm
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
- name: publish
|
|
||||||
pull: always
|
|
||||||
image: plugins/docker:linux-arm
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: linux-arm
|
|
||||||
cache_from: appleboy/drone-telegram
|
|
||||||
daemon_off: false
|
|
||||||
dockerfile: docker/Dockerfile.linux.arm
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: appleboy/drone-telegram
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- pull_request
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- refs/pull/**
|
|
||||||
- refs/tags/**
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- testing
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: release-binary
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build-all-binary
|
|
||||||
pull: always
|
|
||||||
image: golang:1.13
|
|
||||||
commands:
|
|
||||||
- make release
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
- name: deploy-all-binary
|
|
||||||
pull: always
|
|
||||||
image: plugins/github-release
|
|
||||||
settings:
|
|
||||||
api_key:
|
|
||||||
from_secret: github_release_api_key
|
|
||||||
files:
|
|
||||||
- dist/release/*
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/tags/**
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- testing
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: notifications
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: telegram
|
|
||||||
pull: always
|
|
||||||
image: appleboy/drone-telegram
|
|
||||||
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"
|
|
||||||
to:
|
|
||||||
from_secret: telegram_to
|
|
||||||
token:
|
|
||||||
from_secret: telegram_token
|
|
||||||
|
|
||||||
- name: manifest
|
|
||||||
pull: always
|
|
||||||
image: plugins/manifest
|
|
||||||
settings:
|
|
||||||
ignore_missing: true
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
spec: docker/manifest.tmpl
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- refs/tags/**
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- linux-amd64
|
|
||||||
- linux-arm64
|
|
||||||
- linux-arm
|
|
||||||
- release-binary
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: signature
|
|
||||||
hmac: 9a4dcc3659b6f2cb98486e40e4cb0c16d6fc19ad783d3bca13d30c476daf8213
|
|
||||||
|
|
||||||
...
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
# unifying the coding style for different editors and IDEs => editorconfig.org
|
|
||||||
|
|
||||||
; indicate this is the root of the project
|
|
||||||
root = true
|
|
||||||
|
|
||||||
###########################################################
|
|
||||||
; common
|
|
||||||
###########################################################
|
|
||||||
|
|
||||||
[*]
|
|
||||||
charset = utf-8
|
|
||||||
|
|
||||||
end_of_line = LF
|
|
||||||
insert_final_newline = true
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 2
|
|
||||||
|
|
||||||
###########################################################
|
|
||||||
; make
|
|
||||||
###########################################################
|
|
||||||
|
|
||||||
[Makefile]
|
|
||||||
indent_style = tab
|
|
||||||
|
|
||||||
[makefile]
|
|
||||||
indent_style = tab
|
|
||||||
|
|
||||||
###########################################################
|
|
||||||
; markdown
|
|
||||||
###########################################################
|
|
||||||
|
|
||||||
[*.md]
|
|
||||||
trim_trailing_whitespace = false
|
|
||||||
|
|
||||||
###########################################################
|
|
||||||
; golang
|
|
||||||
###########################################################
|
|
||||||
|
|
||||||
[*.go]
|
|
||||||
indent_style = tab
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
|
patreon: # Replace with a single Patreon username
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: # Replace with a single Ko-fi username
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
liberapay: # Replace with a single Liberapay username
|
||||||
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
|
otechie: # Replace with a single Otechie username
|
||||||
|
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||||
|
custom: ['https://www.paypal.me/appleboy46']
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: github-actions
|
||||||
|
directory: /
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
|
- package-ecosystem: gomod
|
||||||
|
directory: /
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
# For most projects, this workflow file will not need changing; you simply need
|
||||||
|
# to commit it to your repository.
|
||||||
|
#
|
||||||
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
|
# or to provide custom queries or build logic.
|
||||||
|
#
|
||||||
|
# ******** NOTE ********
|
||||||
|
# We have attempted to detect the languages in your repository. Please check
|
||||||
|
# the `language` matrix defined below to confirm you have the correct set of
|
||||||
|
# supported CodeQL languages.
|
||||||
|
#
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [master]
|
||||||
|
schedule:
|
||||||
|
- cron: "41 23 * * 6"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
language: ["go"]
|
||||||
|
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||||
|
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v4
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v4
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
name: Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- "master"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Setup go
|
||||||
|
uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version: "^1"
|
||||||
|
check-latest: true
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Build binary
|
||||||
|
run: |
|
||||||
|
make build_linux_amd64
|
||||||
|
make build_linux_arm64
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v4
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v4
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: docker-meta
|
||||||
|
uses: docker/metadata-action@v6
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
${{ github.repository }}
|
||||||
|
ghcr.io/${{ github.repository }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
|
||||||
|
- name: Build image for scanning
|
||||||
|
uses: docker/build-push-action@v7
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: docker/Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: false
|
||||||
|
load: true
|
||||||
|
tags: drone-telegram:scan
|
||||||
|
|
||||||
|
- name: Run Trivy vulnerability scanner
|
||||||
|
uses: aquasecurity/trivy-action@v0.36.0
|
||||||
|
with:
|
||||||
|
image-ref: "drone-telegram:scan"
|
||||||
|
format: "sarif"
|
||||||
|
output: "trivy-image-results.sarif"
|
||||||
|
severity: "CRITICAL,HIGH"
|
||||||
|
exit-code: '1'
|
||||||
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
|
uses: github/codeql-action/upload-sarif@v4
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
sarif_file: "trivy-image-results.sarif"
|
||||||
|
category: "trivy-docker-image"
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v7
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
file: docker/Dockerfile
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.docker-meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.docker-meta.outputs.labels }}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
name: Goreleaser
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
goreleaser:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Setup go
|
||||||
|
uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
check-latest: true
|
||||||
|
|
||||||
|
- name: Run GoReleaser
|
||||||
|
uses: goreleaser/goreleaser-action@v7
|
||||||
|
with:
|
||||||
|
# either 'goreleaser' (default) or 'goreleaser-pro'
|
||||||
|
distribution: goreleaser
|
||||||
|
version: latest
|
||||||
|
args: release --clean
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
name: Lint and Testing
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Setup go
|
||||||
|
uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
check-latest: true
|
||||||
|
|
||||||
|
- name: Setup golangci-lint
|
||||||
|
uses: golangci/golangci-lint-action@v9
|
||||||
|
with:
|
||||||
|
version: v2.12
|
||||||
|
args: --verbose
|
||||||
|
|
||||||
|
- uses: hadolint/hadolint-action@v3.3.0
|
||||||
|
name: hadolint for Dockerfile
|
||||||
|
with:
|
||||||
|
dockerfile: docker/Dockerfile
|
||||||
|
|
||||||
|
test:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
go: [1.25, 1.26]
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
go-build: ~/.cache/go-build
|
||||||
|
name: ${{ matrix.os }} @ Go ${{ matrix.go }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
GO111MODULE: on
|
||||||
|
GOPROXY: https://proxy.golang.org
|
||||||
|
steps:
|
||||||
|
- name: Set up Go ${{ matrix.go }}
|
||||||
|
uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go }}
|
||||||
|
check-latest: true
|
||||||
|
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
|
||||||
|
- uses: actions/cache@v5
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
${{ matrix.go-build }}
|
||||||
|
~/go/pkg/mod
|
||||||
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
make test
|
||||||
|
- name: Upload coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v6
|
||||||
|
with:
|
||||||
|
flags: ${{ matrix.os }},go-${{ matrix.go }}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
name: Trivy Security Scan
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
schedule:
|
||||||
|
# Run daily at 00:00 UTC
|
||||||
|
- cron: "0 0 * * *"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
trivy-repo-scan:
|
||||||
|
name: Trivy Repository Scan
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Run Trivy vulnerability scanner (repo)
|
||||||
|
uses: aquasecurity/trivy-action@v0.36.0
|
||||||
|
with:
|
||||||
|
scan-type: "fs"
|
||||||
|
scan-ref: "."
|
||||||
|
format: "sarif"
|
||||||
|
output: "trivy-repo-results.sarif"
|
||||||
|
severity: "CRITICAL,HIGH"
|
||||||
|
|
||||||
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
|
uses: github/codeql-action/upload-sarif@v4
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
sarif_file: "trivy-repo-results.sarif"
|
||||||
|
|
||||||
|
trivy-image-scan:
|
||||||
|
name: Trivy Image Scan
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Setup go
|
||||||
|
uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
check-latest: true
|
||||||
|
|
||||||
|
- name: Build binary
|
||||||
|
run: |
|
||||||
|
make build_linux_amd64
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
|
- name: Build Docker image for scanning
|
||||||
|
uses: docker/build-push-action@v7
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: docker/Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: false
|
||||||
|
load: true
|
||||||
|
tags: drone-telegram:scan
|
||||||
|
|
||||||
|
- name: Run Trivy vulnerability scanner (image)
|
||||||
|
uses: aquasecurity/trivy-action@v0.36.0
|
||||||
|
with:
|
||||||
|
image-ref: "drone-telegram:scan"
|
||||||
|
format: "sarif"
|
||||||
|
output: "trivy-image-results.sarif"
|
||||||
|
severity: "CRITICAL,HIGH"
|
||||||
|
|
||||||
|
- name: Upload Trivy image scan results to GitHub Security tab
|
||||||
|
uses: github/codeql-action/upload-sarif@v4
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
sarif_file: "trivy-image-results.sarif"
|
||||||
|
category: "trivy-image"
|
||||||
@@ -26,3 +26,4 @@ drone-telegram
|
|||||||
coverage.txt
|
coverage.txt
|
||||||
.env
|
.env
|
||||||
release
|
release
|
||||||
|
bin
|
||||||
|
|||||||
+114
@@ -0,0 +1,114 @@
|
|||||||
|
version: "2"
|
||||||
|
output:
|
||||||
|
sort-order:
|
||||||
|
- file
|
||||||
|
linters:
|
||||||
|
default: none
|
||||||
|
enable:
|
||||||
|
- bidichk
|
||||||
|
- bodyclose
|
||||||
|
- depguard
|
||||||
|
- errcheck
|
||||||
|
- forbidigo
|
||||||
|
- gocheckcompilerdirectives
|
||||||
|
- gocritic
|
||||||
|
- govet
|
||||||
|
- ineffassign
|
||||||
|
- mirror
|
||||||
|
- modernize
|
||||||
|
- nakedret
|
||||||
|
- nilnil
|
||||||
|
- nolintlint
|
||||||
|
- perfsprint
|
||||||
|
- revive
|
||||||
|
- staticcheck
|
||||||
|
- testifylint
|
||||||
|
- unconvert
|
||||||
|
- unparam
|
||||||
|
- unused
|
||||||
|
- usestdlibvars
|
||||||
|
- usetesting
|
||||||
|
- wastedassign
|
||||||
|
settings:
|
||||||
|
depguard:
|
||||||
|
rules:
|
||||||
|
main:
|
||||||
|
deny:
|
||||||
|
- pkg: io/ioutil
|
||||||
|
desc: use os or io instead
|
||||||
|
- pkg: golang.org/x/exp
|
||||||
|
desc: it's experimental and unreliable
|
||||||
|
- pkg: github.com/pkg/errors
|
||||||
|
desc: use builtin errors package instead
|
||||||
|
nolintlint:
|
||||||
|
allow-unused: false
|
||||||
|
require-explanation: true
|
||||||
|
require-specific: true
|
||||||
|
gocritic:
|
||||||
|
enabled-checks:
|
||||||
|
- equalFold
|
||||||
|
disabled-checks: []
|
||||||
|
revive:
|
||||||
|
severity: error
|
||||||
|
rules:
|
||||||
|
- name: blank-imports
|
||||||
|
- name: constant-logical-expr
|
||||||
|
- name: context-as-argument
|
||||||
|
- name: context-keys-type
|
||||||
|
- name: dot-imports
|
||||||
|
- name: empty-lines
|
||||||
|
- name: error-return
|
||||||
|
- name: error-strings
|
||||||
|
- name: exported
|
||||||
|
- name: identical-branches
|
||||||
|
- name: if-return
|
||||||
|
- name: increment-decrement
|
||||||
|
- name: modifies-value-receiver
|
||||||
|
- name: package-comments
|
||||||
|
- name: redefines-builtin-id
|
||||||
|
- name: superfluous-else
|
||||||
|
- name: time-naming
|
||||||
|
- name: unexported-return
|
||||||
|
- name: var-declaration
|
||||||
|
- name: var-naming
|
||||||
|
disabled: true
|
||||||
|
staticcheck:
|
||||||
|
checks:
|
||||||
|
- all
|
||||||
|
testifylint: {}
|
||||||
|
usetesting:
|
||||||
|
os-temp-dir: true
|
||||||
|
perfsprint:
|
||||||
|
concat-loop: false
|
||||||
|
govet:
|
||||||
|
enable:
|
||||||
|
- nilness
|
||||||
|
- unusedwrite
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
presets:
|
||||||
|
- comments
|
||||||
|
- common-false-positives
|
||||||
|
- legacy
|
||||||
|
- std-error-handling
|
||||||
|
rules:
|
||||||
|
- linters:
|
||||||
|
- errcheck
|
||||||
|
- staticcheck
|
||||||
|
- unparam
|
||||||
|
path: _test\.go
|
||||||
|
issues:
|
||||||
|
max-issues-per-linter: 0
|
||||||
|
max-same-issues: 0
|
||||||
|
formatters:
|
||||||
|
enable:
|
||||||
|
- gofmt
|
||||||
|
- gofumpt
|
||||||
|
- golines
|
||||||
|
settings:
|
||||||
|
gofumpt:
|
||||||
|
extra-rules: true
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
run:
|
||||||
|
timeout: 10m
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod tidy
|
||||||
|
|
||||||
|
builds:
|
||||||
|
- env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
goos:
|
||||||
|
- darwin
|
||||||
|
- linux
|
||||||
|
- windows
|
||||||
|
- freebsd
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
- arm
|
||||||
|
- arm64
|
||||||
|
goarm:
|
||||||
|
- "5"
|
||||||
|
- "6"
|
||||||
|
- "7"
|
||||||
|
ignore:
|
||||||
|
- goos: darwin
|
||||||
|
goarch: arm
|
||||||
|
- goos: darwin
|
||||||
|
goarch: ppc64le
|
||||||
|
- goos: darwin
|
||||||
|
goarch: s390x
|
||||||
|
- goos: windows
|
||||||
|
goarch: ppc64le
|
||||||
|
- goos: windows
|
||||||
|
goarch: s390x
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm
|
||||||
|
goarm: "5"
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm
|
||||||
|
goarm: "6"
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm
|
||||||
|
goarm: "7"
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm64
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: ppc64le
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: s390x
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm
|
||||||
|
goarm: "5"
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm
|
||||||
|
goarm: "6"
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm
|
||||||
|
goarm: "7"
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm64
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
ldflags:
|
||||||
|
- -s -w
|
||||||
|
- -X main.Version={{.Version}}
|
||||||
|
binary: >-
|
||||||
|
{{ .ProjectName }}-
|
||||||
|
{{- if .IsSnapshot }}{{ .Branch }}-
|
||||||
|
{{- else }}{{- .Version }}-{{ end }}
|
||||||
|
{{- .Os }}-
|
||||||
|
{{- if eq .Arch "amd64" }}amd64
|
||||||
|
{{- else if eq .Arch "amd64_v1" }}amd64
|
||||||
|
{{- else if eq .Arch "386" }}386
|
||||||
|
{{- else }}{{ .Arch }}{{ end }}
|
||||||
|
{{- if .Arm }}-{{ .Arm }}{{ end }}
|
||||||
|
no_unique_dist_dir: true
|
||||||
|
hooks:
|
||||||
|
post:
|
||||||
|
- cmd: xz -k -9 {{ .Path }}
|
||||||
|
dir: ./dist/
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- format: binary
|
||||||
|
name_template: "{{ .Binary }}"
|
||||||
|
allow_different_binary_count: true
|
||||||
|
|
||||||
|
checksum:
|
||||||
|
name_template: "checksums.txt"
|
||||||
|
extra_files:
|
||||||
|
- glob: ./**.xz
|
||||||
|
|
||||||
|
snapshot:
|
||||||
|
name_template: "{{ incpatch .Version }}"
|
||||||
|
|
||||||
|
release:
|
||||||
|
# You can add extra pre-existing files to the release.
|
||||||
|
# The filename on the release will be the last part of the path (base).
|
||||||
|
# If another file with the same name exists, the last one found will be used.
|
||||||
|
#
|
||||||
|
# Templates: allowed
|
||||||
|
extra_files:
|
||||||
|
- glob: ./**.xz
|
||||||
|
|
||||||
|
changelog:
|
||||||
|
use: github
|
||||||
|
groups:
|
||||||
|
- title: Features
|
||||||
|
regexp: "^.*feat[(\\w)]*:+.*$"
|
||||||
|
order: 0
|
||||||
|
- title: "Bug fixes"
|
||||||
|
regexp: "^.*fix[(\\w)]*:+.*$"
|
||||||
|
order: 1
|
||||||
|
- title: "Enhancements"
|
||||||
|
regexp: "^.*chore[(\\w)]*:+.*$"
|
||||||
|
order: 2
|
||||||
|
- title: "Refactor"
|
||||||
|
regexp: "^.*refactor[(\\w)]*:+.*$"
|
||||||
|
order: 3
|
||||||
|
- title: "Build process updates"
|
||||||
|
regexp: ^.*?(build|ci)(\(.+\))??!?:.+$
|
||||||
|
order: 4
|
||||||
|
- title: "Documentation updates"
|
||||||
|
regexp: ^.*?docs?(\(.+\))??!?:.+$
|
||||||
|
order: 4
|
||||||
|
- title: Others
|
||||||
|
order: 999
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
ignored:
|
||||||
|
- DL3018
|
||||||
|
- DL3008
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
ignoreGeneratedHeader = false
|
|
||||||
severity = "warning"
|
|
||||||
confidence = 0.8
|
|
||||||
errorCode = 1
|
|
||||||
warningCode = 1
|
|
||||||
|
|
||||||
[rule.blank-imports]
|
|
||||||
[rule.context-as-argument]
|
|
||||||
[rule.context-keys-type]
|
|
||||||
[rule.dot-imports]
|
|
||||||
[rule.error-return]
|
|
||||||
[rule.error-strings]
|
|
||||||
[rule.error-naming]
|
|
||||||
[rule.exported]
|
|
||||||
[rule.if-return]
|
|
||||||
[rule.increment-decrement]
|
|
||||||
[rule.var-naming]
|
|
||||||
[rule.var-declaration]
|
|
||||||
[rule.package-comments]
|
|
||||||
[rule.range]
|
|
||||||
[rule.receiver-naming]
|
|
||||||
[rule.time-naming]
|
|
||||||
[rule.unexported-return]
|
|
||||||
[rule.indent-error-flow]
|
|
||||||
[rule.errorf]
|
|
||||||
@@ -1,11 +1,17 @@
|
|||||||
---
|
---
|
||||||
date: 2019-10-19T00:00:00+00:00
|
date: 2019-10-19T00:00:00+00:00
|
||||||
title: Telegram
|
|
||||||
author: appleboy
|
author: appleboy
|
||||||
tags: [ notifications, chat ]
|
containerImage: docker.io/appleboy/drone-telegram
|
||||||
repo: appleboy/drone-telegram
|
containerImageUrl: https://hub.docker.com/r/appleboy/drone-telegram
|
||||||
logo: telegram.svg
|
description: Plugin for sending Telegram notifications
|
||||||
|
icon: https://raw.githubusercontent.com/appleboy/drone-telegram/refs/heads/master/images/logo.svg
|
||||||
image: appleboy/drone-telegram
|
image: appleboy/drone-telegram
|
||||||
|
logo: telegram.svg
|
||||||
|
name: Telegram
|
||||||
|
repo: appleboy/drone-telegram
|
||||||
|
tags: [ notifications, chat ]
|
||||||
|
title: Telegram
|
||||||
|
url: https://github.com/appleboy/drone-telegram
|
||||||
---
|
---
|
||||||
|
|
||||||
The Telegram plugin posts build status messages to your account. The below pipeline configuration demonstrates simple usage:
|
The Telegram plugin posts build status messages to your account. The below pipeline configuration demonstrates simple usage:
|
||||||
@@ -122,7 +128,7 @@ Example configuration with video message:
|
|||||||
+ - tests/video2.mp4
|
+ - tests/video2.mp4
|
||||||
```
|
```
|
||||||
|
|
||||||
Example configuration with message format:
|
Example configuration with message format (`Markdown` or `HTML`), default as `Markdown`:
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
- name: send telegram notification
|
- name: send telegram notification
|
||||||
@@ -130,7 +136,7 @@ Example configuration with message format:
|
|||||||
settings:
|
settings:
|
||||||
token: xxxxxxxxxx
|
token: xxxxxxxxxx
|
||||||
to: telegram_user_id
|
to: telegram_user_id
|
||||||
+ format: markdown
|
+ format: Markdown
|
||||||
```
|
```
|
||||||
|
|
||||||
Example configuration with a custom message template:
|
Example configuration with a custom message template:
|
||||||
@@ -186,6 +192,33 @@ Build finished for *{{tpl.app}}* - *{{tpl.env}}*
|
|||||||
{{/success}}
|
{{/success}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Example configuration with a custom message template, with extra vars loaded from file (e.g. from previous build steps):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
- name: send telegram notification
|
||||||
|
image: appleboy/drone-telegram
|
||||||
|
settings:
|
||||||
|
token: xxxxxxxxxx
|
||||||
|
to: telegram_user_id
|
||||||
|
+ template_vars_file: build_report.json
|
||||||
|
+ message: >
|
||||||
|
+ {{#success build.status}}
|
||||||
|
+ build {{build.number}} succeeded, artefact version = {{tpl.artefact_version}}.
|
||||||
|
+ {{else}}
|
||||||
|
+ build {{build.number}} failed. Fix me please.
|
||||||
|
+ {{/success}}
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `build_report.json` is:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
...
|
||||||
|
"artefact_version": "0.2.3452"
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Example configuration with a custom socks5 URL:
|
Example configuration with a custom socks5 URL:
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
@@ -198,6 +231,30 @@ Example configuration with a custom socks5 URL:
|
|||||||
+ socks5: socks5://67.204.21.1:64312
|
+ socks5: socks5://67.204.21.1:64312
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Disables link previews for links in this message
|
||||||
|
|
||||||
|
```diff
|
||||||
|
- name: send telegram notification
|
||||||
|
image: appleboy/drone-telegram
|
||||||
|
settings:
|
||||||
|
token: xxxxxxxxxx
|
||||||
|
to: telegram_user_id
|
||||||
|
message: send message without a link preview
|
||||||
|
+ disable_web_page_preview: true
|
||||||
|
```
|
||||||
|
|
||||||
|
Disables notifications for this message
|
||||||
|
|
||||||
|
```diff
|
||||||
|
- name: send telegram notification
|
||||||
|
image: appleboy/drone-telegram
|
||||||
|
settings:
|
||||||
|
token: xxxxxxxxxx
|
||||||
|
to: telegram_user_id
|
||||||
|
message: send message message silently
|
||||||
|
+ disable_notification: true
|
||||||
|
```
|
||||||
|
|
||||||
## Parameter Reference
|
## Parameter Reference
|
||||||
|
|
||||||
token
|
token
|
||||||
@@ -215,6 +272,9 @@ message_file
|
|||||||
template_vars
|
template_vars
|
||||||
: define additional template vars. Example: `var1: hello` can be used within the template as `tpl.var1`
|
: define additional template vars. Example: `var1: hello` can be used within the template as `tpl.var1`
|
||||||
|
|
||||||
|
template_vars_file
|
||||||
|
: load additional template vars from json file. Example: given file content `{"var1":"hello"}`, variable can be used within the template as `tpl.var1`
|
||||||
|
|
||||||
photo
|
photo
|
||||||
: local file path
|
: local file path
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
DIST := dist
|
|
||||||
EXECUTABLE := drone-telegram
|
EXECUTABLE := drone-telegram
|
||||||
GOFMT ?= gofmt "-s"
|
GOFMT ?= gofumpt -l
|
||||||
|
DIST := dist
|
||||||
|
DIST_DIRS := $(DIST)/binaries $(DIST)/release
|
||||||
GO ?= go
|
GO ?= go
|
||||||
|
SHASUM ?= shasum -a 256
|
||||||
|
GOFILES := $(shell find . -name "*.go" -type f)
|
||||||
|
HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
|
||||||
|
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
|
||||||
|
XGO_VERSION := go-1.19.x
|
||||||
|
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11
|
||||||
|
|
||||||
# for dockerhub
|
LINUX_ARCHS ?= linux/amd64,linux/arm64
|
||||||
DEPLOY_ACCOUNT := appleboy
|
DARWIN_ARCHS ?= darwin-10.12/amd64,darwin-10.12/arm64
|
||||||
DEPLOY_IMAGE := $(EXECUTABLE)
|
WINDOWS_ARCHS ?= windows/*
|
||||||
|
|
||||||
TARGETS ?= linux darwin windows
|
|
||||||
SOURCES ?= $(shell find . -name "*.go" -type f)
|
|
||||||
TAGS ?=
|
|
||||||
LDFLAGS ?= -X 'main.Version=$(VERSION)'
|
|
||||||
|
|
||||||
ifneq ($(shell uname), Darwin)
|
ifneq ($(shell uname), Darwin)
|
||||||
EXTLDFLAGS = -extldflags "-static" $(null)
|
EXTLDFLAGS = -extldflags "-static" $(null)
|
||||||
@@ -18,76 +20,67 @@ else
|
|||||||
EXTLDFLAGS =
|
EXTLDFLAGS =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(HAS_GO), GO)
|
||||||
|
GOPATH ?= $(shell $(GO) env GOPATH)
|
||||||
|
export PATH := $(GOPATH)/bin:$(PATH)
|
||||||
|
|
||||||
|
CGO_EXTRA_CFLAGS := -DSQLITE_MAX_VARIABLE_NUMBER=32766
|
||||||
|
CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OS), Windows_NT)
|
||||||
|
GOFLAGS := -v -buildmode=exe
|
||||||
|
EXECUTABLE ?= $(EXECUTABLE).exe
|
||||||
|
else ifeq ($(OS), Windows)
|
||||||
|
GOFLAGS := -v -buildmode=exe
|
||||||
|
EXECUTABLE ?= $(EXECUTABLE).exe
|
||||||
|
else
|
||||||
|
GOFLAGS := -v
|
||||||
|
EXECUTABLE ?= $(EXECUTABLE)
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ($(DRONE_TAG),)
|
ifneq ($(DRONE_TAG),)
|
||||||
VERSION ?= $(DRONE_TAG)
|
VERSION ?= $(DRONE_TAG)
|
||||||
else
|
else
|
||||||
VERSION ?= $(shell git describe --tags --always || git rev-parse --short HEAD)
|
VERSION ?= $(shell git describe --tags --always || git rev-parse --short HEAD)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
TAGS ?=
|
||||||
|
LDFLAGS ?= -X 'main.Version=$(VERSION)'
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
$(GOFMT) -w $(SOURCES)
|
@hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
$(GO) install mvdan.cc/gofumpt; \
|
||||||
|
fi
|
||||||
|
$(GOFMT) -w $(GOFILES)
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
$(GO) vet ./...
|
$(GO) vet ./...
|
||||||
|
|
||||||
lint:
|
|
||||||
@hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
$(GO) get -u github.com/mgechev/revive; \
|
|
||||||
fi
|
|
||||||
revive -config .revive.toml ./... || exit 1
|
|
||||||
|
|
||||||
.PHONY: misspell-check
|
|
||||||
misspell-check:
|
|
||||||
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
|
|
||||||
fi
|
|
||||||
misspell -error $(SOURCES)
|
|
||||||
|
|
||||||
.PHONY: misspell
|
|
||||||
misspell:
|
|
||||||
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
||||||
$(GO) get -u github.com/client9/misspell/cmd/misspell; \
|
|
||||||
fi
|
|
||||||
misspell -w $(SOURCES)
|
|
||||||
|
|
||||||
.PHONY: fmt-check
|
.PHONY: fmt-check
|
||||||
fmt-check:
|
fmt-check:
|
||||||
@diff=$$($(GOFMT) -d $(SOURCES)); \
|
@hash gofumpt > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
$(GO) install mvdan.cc/gofumpt; \
|
||||||
|
fi
|
||||||
|
@diff=$$($(GOFMT) -d $(GOFILES)); \
|
||||||
if [ -n "$$diff" ]; then \
|
if [ -n "$$diff" ]; then \
|
||||||
echo "Please run 'make fmt' and commit the result:"; \
|
echo "Please run 'make fmt' and commit the result:"; \
|
||||||
echo "$${diff}"; \
|
echo "$${diff}"; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
test: fmt-check
|
test:
|
||||||
@$(GO) test -v -cover -coverprofile coverage.txt ./... && echo "\n==>\033[32m Ok\033[m\n" || exit 1
|
@$(GO) test -v -cover -coverprofile coverage.txt ./... && echo "\n==>\033[32m Ok\033[m\n" || exit 1
|
||||||
|
|
||||||
install: $(SOURCES)
|
install: $(GOFILES)
|
||||||
$(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)'
|
$(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)'
|
||||||
|
|
||||||
build: $(EXECUTABLE)
|
build: $(EXECUTABLE)
|
||||||
|
|
||||||
$(EXECUTABLE): $(SOURCES)
|
$(EXECUTABLE): $(GOFILES)
|
||||||
$(GO) build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o $@
|
$(GO) build -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o bin/$@
|
||||||
|
|
||||||
release: release-dirs release-build release-copy release-check
|
|
||||||
|
|
||||||
release-dirs:
|
|
||||||
mkdir -p $(DIST)/binaries $(DIST)/release
|
|
||||||
|
|
||||||
release-build:
|
|
||||||
@which gox > /dev/null; if [ $$? -ne 0 ]; then \
|
|
||||||
$(GO) get -u github.com/mitchellh/gox; \
|
|
||||||
fi
|
|
||||||
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));)
|
|
||||||
|
|
||||||
release-check:
|
|
||||||
cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
|
|
||||||
|
|
||||||
build_linux_amd64:
|
build_linux_amd64:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/amd64/$(DEPLOY_IMAGE)
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/amd64/$(DEPLOY_IMAGE)
|
||||||
@@ -101,23 +94,69 @@ build_linux_arm64:
|
|||||||
build_linux_arm:
|
build_linux_arm:
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm/$(DEPLOY_IMAGE)
|
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm/$(DEPLOY_IMAGE)
|
||||||
|
|
||||||
docker_image:
|
ssh-server:
|
||||||
docker build -t $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE) .
|
adduser -h /home/drone-scp -s /bin/sh -D -S drone-scp
|
||||||
|
echo drone-scp:1234 | chpasswd
|
||||||
docker: docker_image
|
mkdir -p /home/drone-scp/.ssh
|
||||||
|
chmod 700 /home/drone-scp/.ssh
|
||||||
docker_deploy:
|
cat tests/.ssh/id_rsa.pub >> /home/drone-scp/.ssh/authorized_keys
|
||||||
ifeq ($(tag),)
|
cat tests/.ssh/test.pub >> /home/drone-scp/.ssh/authorized_keys
|
||||||
@echo "Usage: make $@ tag=<tag>"
|
chmod 600 /home/drone-scp/.ssh/authorized_keys
|
||||||
@exit 1
|
chown -R drone-scp /home/drone-scp/.ssh
|
||||||
endif
|
apk add --update openssh openrc
|
||||||
# deploy image
|
rm -rf /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key
|
||||||
docker tag $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE):latest $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE):$(tag)
|
sed -i 's/^#PubkeyAuthentication yes/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
|
||||||
docker push $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE):$(tag)
|
sed -i 's/AllowTcpForwarding no/AllowTcpForwarding yes/g' /etc/ssh/sshd_config
|
||||||
|
./tests/entrypoint.sh /usr/sbin/sshd -D &
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
sed -i '/main.go/d' coverage.txt
|
sed -i '/main.go/d' coverage.txt
|
||||||
|
|
||||||
|
.PHONY: deps-backend
|
||||||
|
deps-backend:
|
||||||
|
$(GO) mod download
|
||||||
|
$(GO) install $(GXZ_PACKAGE)
|
||||||
|
$(GO) install $(XGO_PACKAGE)
|
||||||
|
|
||||||
|
.PHONY: release
|
||||||
|
release: release-linux release-darwin release-windows release-copy release-compress release-check
|
||||||
|
|
||||||
|
$(DIST_DIRS):
|
||||||
|
mkdir -p $(DIST_DIRS)
|
||||||
|
|
||||||
|
.PHONY: release-windows
|
||||||
|
release-windows: | $(DIST_DIRS)
|
||||||
|
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(WINDOWS_ARCHS)' -out $(EXECUTABLE)-$(VERSION) .
|
||||||
|
ifeq ($(CI),true)
|
||||||
|
cp -r /build/* $(DIST)/binaries/
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: release-linux
|
||||||
|
release-linux: | $(DIST_DIRS)
|
||||||
|
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(LINUX_ARCHS)' -out $(EXECUTABLE)-$(VERSION) .
|
||||||
|
ifeq ($(CI),true)
|
||||||
|
cp -r /build/* $(DIST)/binaries/
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: release-darwin
|
||||||
|
release-darwin: | $(DIST_DIRS)
|
||||||
|
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets '$(DARWIN_ARCHS)' -out $(EXECUTABLE)-$(VERSION) .
|
||||||
|
ifeq ($(CI),true)
|
||||||
|
cp -r /build/* $(DIST)/binaries/
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: release-copy
|
||||||
|
release-copy: | $(DIST_DIRS)
|
||||||
|
cd $(DIST); for file in `find . -type f -name "*"`; do cp $${file} ./release/; done;
|
||||||
|
|
||||||
|
.PHONY: release-check
|
||||||
|
release-check: | $(DIST_DIRS)
|
||||||
|
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;
|
||||||
|
|
||||||
|
.PHONY: release-compress
|
||||||
|
release-compress: | $(DIST_DIRS)
|
||||||
|
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && $(GO) run $(GXZ_PACKAGE) -k -9 $${file}; done;
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(GO) clean -x -i ./...
|
$(GO) clean -x -i ./...
|
||||||
rm -rf coverage.txt $(EXECUTABLE) $(DIST)
|
rm -rf coverage.txt $(EXECUTABLE) $(DIST)
|
||||||
|
|||||||
@@ -3,12 +3,9 @@
|
|||||||

|

|
||||||
|
|
||||||
[](https://godoc.org/github.com/appleboy/drone-telegram)
|
[](https://godoc.org/github.com/appleboy/drone-telegram)
|
||||||
[](https://cloud.drone.io/appleboy/drone-telegram)
|
[](https://github.com/appleboy/drone-telegram/actions/workflows/trivy.yml)
|
||||||
[](https://ci.appveyor.com/project/appleboy/drone-telegram-cd47y)
|
|
||||||
[](https://codecov.io/gh/appleboy/drone-telegram)
|
[](https://codecov.io/gh/appleboy/drone-telegram)
|
||||||
[](https://goreportcard.com/report/github.com/appleboy/drone-telegram)
|
[](https://goreportcard.com/report/github.com/appleboy/drone-telegram)
|
||||||
[](https://hub.docker.com/r/appleboy/drone-telegram/)
|
|
||||||
[](https://microbadger.com/images/appleboy/drone-telegram "Get your own image badge on microbadger.com")
|
|
||||||
|
|
||||||
[Drone](https://github.com/drone/drone) plugin for sending telegram notifications. For the usage
|
[Drone](https://github.com/drone/drone) plugin for sending telegram notifications. For the usage
|
||||||
information and a listing of the available options please take a look at [the docs](http://plugins.drone.io/appleboy/drone-telegram/).
|
information and a listing of the available options please take a look at [the docs](http://plugins.drone.io/appleboy/drone-telegram/).
|
||||||
@@ -103,7 +100,7 @@ Load all environments from file.
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-e ENV_FILE=your_env_file_path \
|
-e PLUGIN_ENV_FILE=your_env_file_path \
|
||||||
-v $(pwd):$(pwd) \
|
-v $(pwd):$(pwd) \
|
||||||
-w $(pwd) \
|
-w $(pwd) \
|
||||||
appleboy/drone-telegram
|
appleboy/drone-telegram
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
FROM alpine:3.23
|
||||||
|
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
||||||
|
org.label-schema.name="Telegram Plugin" \
|
||||||
|
org.label-schema.vendor="Bo-Yi Wu" \
|
||||||
|
org.label-schema.schema-version="1.0"
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.source=https://github.com/appleboy/drone-telegram
|
||||||
|
LABEL org.opencontainers.image.description="plugin for sending telegram notifications"
|
||||||
|
LABEL org.opencontainers.image.licenses=MIT
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates && \
|
||||||
|
rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
|
COPY release/${TARGETOS}/${TARGETARCH}/drone-telegram /bin/
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/drone-telegram"]
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
FROM plugins/base:linux-amd64
|
|
||||||
|
|
||||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
|
||||||
org.label-schema.name="Drone telegram" \
|
|
||||||
org.label-schema.vendor="Bo-Yi Wu" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
COPY release/linux/amd64/drone-telegram /bin/
|
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/drone-telegram"]
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
FROM plugins/base:linux-arm
|
|
||||||
|
|
||||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
|
||||||
org.label-schema.name="Drone telegram" \
|
|
||||||
org.label-schema.vendor="Bo-Yi Wu" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
COPY release/linux/arm/drone-telegram /bin/
|
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/drone-telegram"]
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
FROM plugins/base:linux-arm64
|
|
||||||
|
|
||||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
|
||||||
org.label-schema.name="Drone telegram" \
|
|
||||||
org.label-schema.vendor="Bo-Yi Wu" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
COPY release/linux/arm64/drone-telegram /bin/
|
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/drone-telegram"]
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
FROM microsoft/nanoserver:10.0.14393.1884
|
|
||||||
|
|
||||||
LABEL maintainer="Bo-Yi Wu <appleboy.tw@gmail.com>" \
|
|
||||||
org.label-schema.name="Drone telegram" \
|
|
||||||
org.label-schema.vendor="Bo-Yi Wu" \
|
|
||||||
org.label-schema.schema-version="1.0"
|
|
||||||
|
|
||||||
COPY release/drone-telegram.exe /drone-telegram.exe
|
|
||||||
|
|
||||||
ENTRYPOINT [ "\\drone-telegram.exe" ]
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
image: appleboy/drone-telegram:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
|
||||||
{{#if build.tags}}
|
|
||||||
tags:
|
|
||||||
{{#each build.tags}}
|
|
||||||
- {{this}}
|
|
||||||
{{/each}}
|
|
||||||
{{/if}}
|
|
||||||
manifests:
|
|
||||||
-
|
|
||||||
image: appleboy/drone-telegram:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: linux
|
|
||||||
-
|
|
||||||
image: appleboy/drone-telegram:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
|
||||||
platform:
|
|
||||||
architecture: arm64
|
|
||||||
os: linux
|
|
||||||
variant: v8
|
|
||||||
-
|
|
||||||
image: appleboy/drone-telegram:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
|
||||||
platform:
|
|
||||||
architecture: arm
|
|
||||||
os: linux
|
|
||||||
variant: v7
|
|
||||||
@@ -1,14 +1,34 @@
|
|||||||
module github.com/appleboy/drone-telegram
|
module github.com/appleboy/drone-telegram
|
||||||
|
|
||||||
go 1.11
|
go 1.25.10
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/drone/drone-template-lib v1.0.0
|
github.com/appleboy/drone-template-lib v1.3.0
|
||||||
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible // indirect
|
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible
|
||||||
github.com/joho/godotenv v1.3.0
|
github.com/joho/godotenv v1.5.1
|
||||||
github.com/stretchr/testify v1.3.0
|
github.com/stretchr/testify v1.9.0
|
||||||
github.com/technoweenie/multipartstreamer v1.0.1 // indirect
|
github.com/urfave/cli v1.22.15
|
||||||
github.com/urfave/cli v1.20.0
|
)
|
||||||
gopkg.in/telegram-bot-api.v4 v4.6.4
|
|
||||||
gopkg.in/yaml.v2 v2.2.2 // indirect
|
require (
|
||||||
|
dario.cat/mergo v1.0.1 // indirect
|
||||||
|
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||||
|
github.com/Masterminds/semver/v3 v3.3.0 // indirect
|
||||||
|
github.com/Masterminds/sprig/v3 v3.3.0 // indirect
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
|
github.com/huandu/xstrings v1.5.0 // indirect
|
||||||
|
github.com/mailgun/raymond/v2 v2.0.48 // indirect
|
||||||
|
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||||
|
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
|
github.com/shopspring/decimal v1.4.0 // indirect
|
||||||
|
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||||
|
github.com/spf13/cast v1.7.0 // indirect
|
||||||
|
github.com/technoweenie/multipartstreamer v1.0.1 // indirect
|
||||||
|
golang.org/x/crypto v0.45.0 // indirect
|
||||||
|
golang.org/x/sys v0.38.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,45 +1,79 @@
|
|||||||
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
|
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
|
||||||
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
||||||
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
|
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||||
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
|
||||||
github.com/Masterminds/sprig v2.18.0+incompatible h1:QoGhlbC6pter1jxKnjMFxT8EqsLuDE6FEcNbWEpw+lI=
|
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
|
||||||
github.com/Masterminds/sprig v2.18.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
|
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
|
||||||
github.com/aymerick/raymond v2.0.2+incompatible h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0=
|
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||||
github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
|
github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs=
|
||||||
github.com/bouk/monkey v1.0.0 h1:k6z8fLlPhETfn5l9rlWVE7Q6B23DoaqosTdArvNQRdc=
|
github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0=
|
||||||
github.com/bouk/monkey v1.0.0/go.mod h1:PG/63f4XEUlVyW1ttIeOJmJhhe1+t9EC/je3eTjvFhE=
|
github.com/appleboy/drone-template-lib v1.3.0 h1:aX36/1za3v8JsEyBeMY1Bp/VNRtZa8qPYkfkjBszW+A=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/appleboy/drone-template-lib v1.3.0/go.mod h1:edlmXkFMKYAVypff8r2oN7aFlHfOZE5sLyPEnRHONeA=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/drone/drone-template-lib v1.0.0 h1:PNBBfUhifRnrPCoWBlTitk3jipXdv8u8WLbIf7h7j00=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/drone/drone-template-lib v1.0.0/go.mod h1:Hqy1tgqPH5mtbFOZmow19l4jOkZvp+WZ00cB4W3MJhg=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||||
|
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||||
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU=
|
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU=
|
||||||
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM=
|
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM=
|
||||||
github.com/google/uuid v1.1.0 h1:Jf4mxPC/ziBnoPIdpQdPJ9OeiomAUHLvxmPRSPH9m4s=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
|
github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
|
||||||
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
|
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/mailgun/raymond/v2 v2.0.48 h1:5dmlB680ZkFG2RN/0lvTAghrSxIESeu9/2aeDqACtjw=
|
||||||
|
github.com/mailgun/raymond/v2 v2.0.48/go.mod h1:lsgvL50kgt1ylcFJYZiULi5fjPBkkhNfj4KA0W54Z18=
|
||||||
|
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
|
||||||
|
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
|
||||||
|
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
|
||||||
|
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||||
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
|
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||||
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
||||||
|
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
|
||||||
|
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||||
|
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||||
|
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
|
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
|
||||||
|
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||||
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM=
|
github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM=
|
||||||
github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog=
|
github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog=
|
||||||
github.com/tkuchiki/faketime v0.0.0-20170607100027-a4500a4f4643 h1:ii/sHfgFMByozryLeiDmn1ClZ/Pena4NgpJ4P7UuX9o=
|
github.com/urfave/cli v1.22.15 h1:nuqt+pdC/KqswQKhETJjo7pvn/k4xMUxgW6liI7XpnM=
|
||||||
github.com/tkuchiki/faketime v0.0.0-20170607100027-a4500a4f4643/go.mod h1:RXY/TXAwGGL36IKDjrHFMcjpUrEiyWSEtLhFPw3UWF0=
|
github.com/urfave/cli v1.22.15/go.mod h1:wSan1hmo5zeyLGBjRJbzRTNk8gwoYa2B9n4q9dmRIc0=
|
||||||
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
|
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
||||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
||||||
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67 h1:ng3VDlRp5/DHpSWl02R4rM9I+8M2rhmsuLwAMmkLQWE=
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||||
|
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
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/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/telegram-bot-api.v4 v4.6.4 h1:hpHWhzn4jTCsAJZZ2loNKfy2QWyPDRJVl3aTFXeMW8g=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/telegram-bot-api.v4 v4.6.4/go.mod h1:5DpGO5dbumb40px+dXcwCpcjmeHNYLpk0bp3XRNvWDM=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,6 +14,15 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
// Load env-file if it exists first
|
||||||
|
if filename, found := os.LookupEnv("PLUGIN_ENV_FILE"); found {
|
||||||
|
_ = godotenv.Load(filename)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := os.Stat("/run/drone/env"); err == nil {
|
||||||
|
_ = godotenv.Overload("/run/drone/env")
|
||||||
|
}
|
||||||
|
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "telegram plugin"
|
app.Name = "telegram plugin"
|
||||||
app.Usage = "telegram plugin"
|
app.Usage = "telegram plugin"
|
||||||
@@ -46,6 +54,11 @@ func main() {
|
|||||||
Usage: "additional template vars to be used in message, as JSON string",
|
Usage: "additional template vars to be used in message, as JSON string",
|
||||||
EnvVar: "PLUGIN_TEMPLATE_VARS,TELEGRAM_TEMPLATE_VARS,INPUT_TEMPLATE_VARS",
|
EnvVar: "PLUGIN_TEMPLATE_VARS,TELEGRAM_TEMPLATE_VARS,INPUT_TEMPLATE_VARS",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "template.vars.file",
|
||||||
|
Usage: "load additional template vars to be used in message, from json file",
|
||||||
|
EnvVar: "PLUGIN_TEMPLATE_VARS_FILE,TELEGRAM_TEMPLATE_VARS_FILE",
|
||||||
|
},
|
||||||
cli.StringSliceFlag{
|
cli.StringSliceFlag{
|
||||||
Name: "photo",
|
Name: "photo",
|
||||||
Usage: "send photo message",
|
Usage: "send photo message",
|
||||||
@@ -96,15 +109,20 @@ func main() {
|
|||||||
Usage: "send message when only match email",
|
Usage: "send message when only match email",
|
||||||
EnvVar: "PLUGIN_ONLY_MATCH_EMAIL,INPUT_ONLY_MATCH_EMAIL",
|
EnvVar: "PLUGIN_ONLY_MATCH_EMAIL,INPUT_ONLY_MATCH_EMAIL",
|
||||||
},
|
},
|
||||||
cli.BoolTFlag{
|
cli.BoolFlag{
|
||||||
Name: "webpage.preview",
|
Name: "disable.webpage.preview",
|
||||||
Usage: "toggle web-page preview",
|
Usage: "disables link previews for links in this message",
|
||||||
EnvVar: "PLUGIN_WEBPAGE_PREVIEW,INPUT_WEBPAGE_PREVIEW",
|
EnvVar: "PLUGIN_DISABLE_WEB_PAGE_PREVIEW,INPUT_DISABLE_WEB_PAGE_PREVIEW",
|
||||||
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "disable.notification",
|
||||||
|
Usage: "sends the message silently. users will receive a notification with no sound.",
|
||||||
|
EnvVar: "PLUGIN_DISABLE_NOTIFICATION,INPUT_DISABLE_NOTIFICATION",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "format",
|
Name: "format",
|
||||||
Value: formatMarkdown,
|
Value: formatMarkdown,
|
||||||
Usage: "telegram message format",
|
Usage: "telegram message format (Markdown or HTML)",
|
||||||
EnvVar: "PLUGIN_FORMAT,FORMAT,INPUT_FORMAT",
|
EnvVar: "PLUGIN_FORMAT,FORMAT,INPUT_FORMAT",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
@@ -195,21 +213,16 @@ func main() {
|
|||||||
Usage: "pull request",
|
Usage: "pull request",
|
||||||
EnvVar: "DRONE_PULL_REQUEST",
|
EnvVar: "DRONE_PULL_REQUEST",
|
||||||
},
|
},
|
||||||
cli.Float64Flag{
|
cli.Int64Flag{
|
||||||
Name: "job.started",
|
Name: "build.started",
|
||||||
Usage: "job started",
|
Usage: "build started",
|
||||||
EnvVar: "DRONE_BUILD_STARTED",
|
EnvVar: "DRONE_STAGE_STARTED",
|
||||||
},
|
},
|
||||||
cli.Float64Flag{
|
cli.Int64Flag{
|
||||||
Name: "job.finished",
|
Name: "build.finished",
|
||||||
Usage: "job finished",
|
Usage: "build finished",
|
||||||
EnvVar: "DRONE_BUILD_FINISHED",
|
EnvVar: "DRONE_BUILD_FINISHED",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
|
||||||
Name: "env-file",
|
|
||||||
Usage: "source env file",
|
|
||||||
EnvVar: "ENV_FILE",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "github",
|
Name: "github",
|
||||||
Usage: "Boolean value, indicates the runtime environment is GitHub Action.",
|
Usage: "Boolean value, indicates the runtime environment is GitHub Action.",
|
||||||
@@ -258,10 +271,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func run(c *cli.Context) error {
|
func run(c *cli.Context) error {
|
||||||
if c.String("env-file") != "" {
|
|
||||||
_ = godotenv.Load(c.String("env-file"))
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
GitHub: GitHub{
|
GitHub: GitHub{
|
||||||
Workflow: c.String("github.workflow"),
|
Workflow: c.String("github.workflow"),
|
||||||
@@ -291,31 +300,34 @@ func run(c *cli.Context) error {
|
|||||||
Event: c.String("build.event"),
|
Event: c.String("build.event"),
|
||||||
Status: c.String("build.status"),
|
Status: c.String("build.status"),
|
||||||
Link: c.String("build.link"),
|
Link: c.String("build.link"),
|
||||||
Started: c.Float64("job.started"),
|
Started: c.Int64("build.started"),
|
||||||
Finished: c.Float64("job.finished"),
|
Finished: c.Int64("build.finished"),
|
||||||
PR: c.String("pull.request"),
|
PR: c.String("pull.request"),
|
||||||
DeployTo: c.String("deploy.to"),
|
DeployTo: c.String("deploy.to"),
|
||||||
},
|
},
|
||||||
Config: Config{
|
Config: Config{
|
||||||
Token: c.String("token"),
|
Token: c.String("token"),
|
||||||
Debug: c.Bool("debug"),
|
Debug: c.Bool("debug"),
|
||||||
MatchEmail: c.Bool("match.email"),
|
MatchEmail: c.Bool("match.email"),
|
||||||
WebPreview: c.Bool("webpage.preview"),
|
To: c.StringSlice("to"),
|
||||||
To: c.StringSlice("to"),
|
Message: c.String("message"),
|
||||||
Message: c.String("message"),
|
MessageFile: c.String("message.file"),
|
||||||
MessageFile: c.String("message.file"),
|
TemplateVars: c.String("template.vars"),
|
||||||
TemplateVars: c.String("template.vars"),
|
TemplateVarsFile: c.String("template.vars.file"),
|
||||||
Photo: c.StringSlice("photo"),
|
Photo: c.StringSlice("photo"),
|
||||||
Document: c.StringSlice("document"),
|
Document: c.StringSlice("document"),
|
||||||
Sticker: c.StringSlice("sticker"),
|
Sticker: c.StringSlice("sticker"),
|
||||||
Audio: c.StringSlice("audio"),
|
Audio: c.StringSlice("audio"),
|
||||||
Voice: c.StringSlice("voice"),
|
Voice: c.StringSlice("voice"),
|
||||||
Location: c.StringSlice("location"),
|
Location: c.StringSlice("location"),
|
||||||
Video: c.StringSlice("video"),
|
Video: c.StringSlice("video"),
|
||||||
Venue: c.StringSlice("venue"),
|
Venue: c.StringSlice("venue"),
|
||||||
Format: c.String("format"),
|
Format: c.String("format"),
|
||||||
GitHub: c.Bool("github"),
|
GitHub: c.Bool("github"),
|
||||||
Socks5: c.String("socks5"),
|
Socks5: c.String("socks5"),
|
||||||
|
|
||||||
|
DisableWebPagePreview: c.Bool("disable.webpage.preview"),
|
||||||
|
DisableNotification: c.Bool("disable.notification"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,268 +0,0 @@
|
|||||||
{
|
|
||||||
test:: {
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: 'testing',
|
|
||||||
platform: {
|
|
||||||
os: 'linux',
|
|
||||||
arch: 'amd64',
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
name: 'vet',
|
|
||||||
image: 'golang:1.13',
|
|
||||||
pull: 'always',
|
|
||||||
commands: [
|
|
||||||
'make vet',
|
|
||||||
],
|
|
||||||
volumes: [
|
|
||||||
{
|
|
||||||
name: 'gopath',
|
|
||||||
path: '/go',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'lint',
|
|
||||||
image: 'golang:1.13',
|
|
||||||
pull: 'always',
|
|
||||||
commands: [
|
|
||||||
'make lint',
|
|
||||||
],
|
|
||||||
volumes: [
|
|
||||||
{
|
|
||||||
name: 'gopath',
|
|
||||||
path: '/go',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'misspell',
|
|
||||||
image: 'golang:1.13',
|
|
||||||
pull: 'always',
|
|
||||||
commands: [
|
|
||||||
'make misspell-check',
|
|
||||||
],
|
|
||||||
volumes: [
|
|
||||||
{
|
|
||||||
name: 'gopath',
|
|
||||||
path: '/go',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'test',
|
|
||||||
image: 'golang:1.13',
|
|
||||||
pull: 'always',
|
|
||||||
environment: {
|
|
||||||
TELEGRAM_TOKEN: { 'from_secret': 'telegram_token' },
|
|
||||||
TELEGRAM_TO: { 'from_secret': 'telegram_to' },
|
|
||||||
},
|
|
||||||
commands: [
|
|
||||||
'make test',
|
|
||||||
'make coverage',
|
|
||||||
],
|
|
||||||
volumes: [
|
|
||||||
{
|
|
||||||
name: 'gopath',
|
|
||||||
path: '/go',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'codecov',
|
|
||||||
image: 'robertstettner/drone-codecov',
|
|
||||||
pull: 'always',
|
|
||||||
settings: {
|
|
||||||
token: { 'from_secret': 'codecov_token' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
volumes: [
|
|
||||||
{
|
|
||||||
name: 'gopath',
|
|
||||||
temp: {},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
|
|
||||||
build(name, os='linux', arch='amd64'):: {
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: os + '-' + arch,
|
|
||||||
platform: {
|
|
||||||
os: os,
|
|
||||||
arch: arch,
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
name: 'build-push',
|
|
||||||
image: 'golang:1.13',
|
|
||||||
pull: 'always',
|
|
||||||
environment: {
|
|
||||||
CGO_ENABLED: '0',
|
|
||||||
},
|
|
||||||
commands: [
|
|
||||||
'go build -v -ldflags \'-X main.build=${DRONE_BUILD_NUMBER}\' -a -o release/' + os + '/' + arch + '/' + name,
|
|
||||||
],
|
|
||||||
when: {
|
|
||||||
event: {
|
|
||||||
exclude: [ 'tag' ],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'build-tag',
|
|
||||||
image: 'golang:1.13',
|
|
||||||
pull: 'always',
|
|
||||||
environment: {
|
|
||||||
CGO_ENABLED: '0',
|
|
||||||
},
|
|
||||||
commands: [
|
|
||||||
'go build -v -ldflags \'-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\' -a -o release/' + os + '/' + arch + '/' + name,
|
|
||||||
],
|
|
||||||
when: {
|
|
||||||
event: [ 'tag' ],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'executable',
|
|
||||||
image: 'golang:1.13',
|
|
||||||
pull: 'always',
|
|
||||||
commands: [
|
|
||||||
'./release/' + os + '/' + arch + '/' + name + ' --help',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'dryrun',
|
|
||||||
image: 'plugins/docker:' + os + '-' + arch,
|
|
||||||
pull: 'always',
|
|
||||||
settings: {
|
|
||||||
daemon_off: false,
|
|
||||||
dry_run: true,
|
|
||||||
tags: os + '-' + arch,
|
|
||||||
dockerfile: 'docker/Dockerfile.' + os + '.' + arch,
|
|
||||||
repo: 'appleboy/' + name,
|
|
||||||
cache_from: 'appleboy/' + name,
|
|
||||||
},
|
|
||||||
when: {
|
|
||||||
event: [ 'pull_request' ],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'publish',
|
|
||||||
image: 'plugins/docker:' + os + '-' + arch,
|
|
||||||
pull: 'always',
|
|
||||||
settings: {
|
|
||||||
daemon_off: 'false',
|
|
||||||
auto_tag: true,
|
|
||||||
auto_tag_suffix: os + '-' + arch,
|
|
||||||
dockerfile: 'docker/Dockerfile.' + os + '.' + arch,
|
|
||||||
repo: 'appleboy/' + name,
|
|
||||||
cache_from: 'appleboy/' + name,
|
|
||||||
username: { 'from_secret': 'docker_username' },
|
|
||||||
password: { 'from_secret': 'docker_password' },
|
|
||||||
},
|
|
||||||
when: {
|
|
||||||
event: {
|
|
||||||
exclude: [ 'pull_request' ],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
depends_on: [
|
|
||||||
'testing',
|
|
||||||
],
|
|
||||||
trigger: {
|
|
||||||
ref: [
|
|
||||||
'refs/heads/master',
|
|
||||||
'refs/pull/**',
|
|
||||||
'refs/tags/**',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
release:: {
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: 'release-binary',
|
|
||||||
platform: {
|
|
||||||
os: 'linux',
|
|
||||||
arch: 'amd64',
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
name: 'build-all-binary',
|
|
||||||
image: 'golang:1.13',
|
|
||||||
pull: 'always',
|
|
||||||
commands: [
|
|
||||||
'make release'
|
|
||||||
],
|
|
||||||
when: {
|
|
||||||
event: [ 'tag' ],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'deploy-all-binary',
|
|
||||||
image: 'plugins/github-release',
|
|
||||||
pull: 'always',
|
|
||||||
settings: {
|
|
||||||
files: [ 'dist/release/*' ],
|
|
||||||
api_key: { 'from_secret': 'github_release_api_key' },
|
|
||||||
},
|
|
||||||
when: {
|
|
||||||
event: [ 'tag' ],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
depends_on: [
|
|
||||||
'testing',
|
|
||||||
],
|
|
||||||
trigger: {
|
|
||||||
ref: [
|
|
||||||
'refs/tags/**',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
notifications(os='linux', arch='amd64', depends_on=[]):: {
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: 'notifications',
|
|
||||||
platform: {
|
|
||||||
os: os,
|
|
||||||
arch: arch,
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
name: 'telegram',
|
|
||||||
image: 'appleboy/drone-telegram',
|
|
||||||
pull: 'always',
|
|
||||||
settings: {
|
|
||||||
to: { from_secret: 'telegram_to' },
|
|
||||||
token: { from_secret: 'telegram_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',
|
|
||||||
pull: 'always',
|
|
||||||
settings: {
|
|
||||||
username: { from_secret: 'docker_username' },
|
|
||||||
password: { from_secret: 'docker_password' },
|
|
||||||
spec: 'docker/manifest.tmpl',
|
|
||||||
ignore_missing: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
depends_on: depends_on,
|
|
||||||
trigger: {
|
|
||||||
ref: [
|
|
||||||
'refs/heads/master',
|
|
||||||
'refs/tags/**',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
signature(key):: {
|
|
||||||
kind: 'signature',
|
|
||||||
hmac: key,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
|
"maps"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@@ -15,12 +14,13 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/drone/drone-template-lib/template"
|
"github.com/appleboy/drone-template-lib/template"
|
||||||
tgbotapi "gopkg.in/telegram-bot-api.v4"
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
formatMarkdown = "markdown"
|
formatMarkdown = "Markdown"
|
||||||
|
formatHTML = "HTML"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@@ -59,33 +59,36 @@ type (
|
|||||||
Number int
|
Number int
|
||||||
Status string
|
Status string
|
||||||
Link string
|
Link string
|
||||||
Started float64
|
Started int64
|
||||||
Finished float64
|
Finished int64
|
||||||
PR string
|
PR string
|
||||||
DeployTo string
|
DeployTo string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config for the plugin.
|
// Config for the plugin.
|
||||||
Config struct {
|
Config struct {
|
||||||
Token string
|
Token string
|
||||||
Debug bool
|
Debug bool
|
||||||
MatchEmail bool
|
MatchEmail bool
|
||||||
WebPreview bool
|
To []string
|
||||||
To []string
|
Message string
|
||||||
Message string
|
MessageFile string
|
||||||
MessageFile string
|
TemplateVarsFile string
|
||||||
TemplateVars string
|
TemplateVars string
|
||||||
Photo []string
|
Photo []string
|
||||||
Document []string
|
Document []string
|
||||||
Sticker []string
|
Sticker []string
|
||||||
Audio []string
|
Audio []string
|
||||||
Voice []string
|
Voice []string
|
||||||
Location []string
|
Location []string
|
||||||
Video []string
|
Video []string
|
||||||
Venue []string
|
Venue []string
|
||||||
Format string
|
Format string
|
||||||
GitHub bool
|
GitHub bool
|
||||||
Socks5 string
|
Socks5 string
|
||||||
|
|
||||||
|
DisableWebPagePreview bool
|
||||||
|
DisableNotification bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin values.
|
// Plugin values.
|
||||||
@@ -114,10 +117,10 @@ var icons = map[string]string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func trimElement(keys []string) []string {
|
func trimElement(keys []string) []string {
|
||||||
var newKeys []string
|
newKeys := make([]string, 0, len(keys))
|
||||||
|
|
||||||
for _, value := range keys {
|
for _, value := range keys {
|
||||||
value = strings.Trim(value, " ")
|
value = strings.TrimSpace(value)
|
||||||
if len(value) == 0 {
|
if len(value) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -128,7 +131,7 @@ func trimElement(keys []string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func escapeMarkdown(keys []string) []string {
|
func escapeMarkdown(keys []string) []string {
|
||||||
var newKeys []string
|
newKeys := make([]string, 0, len(keys))
|
||||||
|
|
||||||
for _, value := range keys {
|
for _, value := range keys {
|
||||||
value = escapeMarkdownOne(value)
|
value = escapeMarkdownOne(value)
|
||||||
@@ -142,20 +145,26 @@ func escapeMarkdown(keys []string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func escapeMarkdownOne(str string) string {
|
func escapeMarkdownOne(str string) string {
|
||||||
str = strings.Replace(str, `\_`, `_`, -1)
|
str = strings.ReplaceAll(str, `\_`, `_`)
|
||||||
str = strings.Replace(str, `_`, `\_`, -1)
|
str = strings.ReplaceAll(str, `_`, `\_`)
|
||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func escapeMarkdownFields(fields ...*string) {
|
||||||
|
for _, f := range fields {
|
||||||
|
*f = escapeMarkdownOne(*f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func globList(keys []string) []string {
|
func globList(keys []string) []string {
|
||||||
var newKeys []string
|
newKeys := make([]string, 0, len(keys))
|
||||||
|
|
||||||
for _, pattern := range keys {
|
for _, pattern := range keys {
|
||||||
pattern = strings.Trim(pattern, " ")
|
pattern = strings.TrimSpace(pattern)
|
||||||
matches, err := filepath.Glob(pattern)
|
matches, err := filepath.Glob(pattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Glob error for %q: %s\n", pattern, err)
|
log.Printf("Glob error for %q: %s", pattern, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
newKeys = append(newKeys, matches...)
|
newKeys = append(newKeys, matches...)
|
||||||
@@ -179,19 +188,16 @@ func convertLocation(value string) (Location, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(values) > 3 {
|
if len(values) > 3 {
|
||||||
title = values[2]
|
|
||||||
address = values[3]
|
address = values[3]
|
||||||
}
|
}
|
||||||
|
|
||||||
latitude, err = strconv.ParseFloat(values[0], 64)
|
latitude, err = strconv.ParseFloat(values[0], 64)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err.Error())
|
log.Println(err.Error())
|
||||||
return Location{}, true
|
return Location{}, true
|
||||||
}
|
}
|
||||||
|
|
||||||
longitude, err = strconv.ParseFloat(values[1], 64)
|
longitude, err = strconv.ParseFloat(values[1], 64)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err.Error())
|
log.Println(err.Error())
|
||||||
return Location{}, true
|
return Location{}, true
|
||||||
@@ -206,13 +212,7 @@ func convertLocation(value string) (Location, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadTextFromFile(filename string) ([]string, error) {
|
func loadTextFromFile(filename string) ([]string, error) {
|
||||||
f, err := os.Open(filename)
|
content, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
r := bufio.NewReader(f)
|
|
||||||
content, err := ioutil.ReadAll(r)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -257,7 +257,7 @@ func parseTo(to []string, authorEmail string, matchEmail bool) []int64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Exec executes the plugin.
|
// Exec executes the plugin.
|
||||||
func (p Plugin) Exec() (err error) {
|
func (p *Plugin) Exec() (err error) {
|
||||||
if len(p.Config.Token) == 0 || len(p.Config.To) == 0 {
|
if len(p.Config.Token) == 0 || len(p.Config.To) == 0 {
|
||||||
return errors.New("missing telegram token or user list")
|
return errors.New("missing telegram token or user list")
|
||||||
}
|
}
|
||||||
@@ -267,7 +267,7 @@ func (p Plugin) Exec() (err error) {
|
|||||||
case len(p.Config.MessageFile) > 0:
|
case len(p.Config.MessageFile) > 0:
|
||||||
message, err = loadTextFromFile(p.Config.MessageFile)
|
message, err = loadTextFromFile(p.Config.MessageFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error loading message file '%s': %v", p.Config.MessageFile, err)
|
return fmt.Errorf("error loading message file '%s': %w", p.Config.MessageFile, err)
|
||||||
}
|
}
|
||||||
case len(p.Config.Message) > 0:
|
case len(p.Config.Message) > 0:
|
||||||
message = []string{p.Config.Message}
|
message = []string{p.Config.Message}
|
||||||
@@ -279,17 +279,46 @@ func (p Plugin) Exec() (err error) {
|
|||||||
if p.Config.TemplateVars != "" {
|
if p.Config.TemplateVars != "" {
|
||||||
p.Tpl = make(map[string]string)
|
p.Tpl = make(map[string]string)
|
||||||
if err = json.Unmarshal([]byte(p.Config.TemplateVars), &p.Tpl); err != nil {
|
if err = json.Unmarshal([]byte(p.Config.TemplateVars), &p.Tpl); err != nil {
|
||||||
return fmt.Errorf("unable to unmarshall template vars from JSON string '%s': %v", p.Config.TemplateVars, err)
|
return fmt.Errorf(
|
||||||
|
"unable to unmarshal template vars from JSON string '%s': %w",
|
||||||
|
p.Config.TemplateVars,
|
||||||
|
err,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var proxyURL *url.URL
|
if p.Config.TemplateVarsFile != "" {
|
||||||
if proxyURL, err = url.Parse(p.Config.Socks5); err != nil {
|
content, err := os.ReadFile(p.Config.TemplateVarsFile)
|
||||||
return fmt.Errorf("unable to unmarshall socks5 proxy url from string '%s': %v", p.Config.Socks5, err)
|
if err != nil {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"unable to read file with template vars '%s': %w",
|
||||||
|
p.Config.TemplateVarsFile,
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
vars := make(map[string]string)
|
||||||
|
if err = json.Unmarshal(content, &vars); err != nil {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"unable to unmarshal template vars from JSON file '%s': %w",
|
||||||
|
p.Config.TemplateVarsFile,
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// File variables take precedence over inline variables
|
||||||
|
if p.Tpl == nil {
|
||||||
|
p.Tpl = vars
|
||||||
|
} else {
|
||||||
|
maps.Copy(p.Tpl, vars)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var bot *tgbotapi.BotAPI
|
var bot *tgbotapi.BotAPI
|
||||||
if len(p.Config.Socks5) > 0 {
|
if len(p.Config.Socks5) > 0 {
|
||||||
|
var proxyURL *url.URL
|
||||||
|
proxyURL, err = url.Parse(p.Config.Socks5)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to parse socks5 proxy URL '%s': %w", p.Config.Socks5, err)
|
||||||
|
}
|
||||||
proxyClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
|
proxyClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
|
||||||
bot, err = tgbotapi.NewBotAPIWithClient(p.Config.Token, proxyClient)
|
bot, err = tgbotapi.NewBotAPIWithClient(p.Config.Token, proxyClient)
|
||||||
} else {
|
} else {
|
||||||
@@ -303,12 +332,12 @@ func (p Plugin) Exec() (err error) {
|
|||||||
bot.Debug = p.Config.Debug
|
bot.Debug = p.Config.Debug
|
||||||
|
|
||||||
ids := parseTo(p.Config.To, p.Commit.Email, p.Config.MatchEmail)
|
ids := parseTo(p.Config.To, p.Commit.Email, p.Config.MatchEmail)
|
||||||
photos := globList(trimElement(p.Config.Photo))
|
photos := globList(p.Config.Photo)
|
||||||
documents := globList(trimElement(p.Config.Document))
|
documents := globList(p.Config.Document)
|
||||||
stickers := globList(trimElement(p.Config.Sticker))
|
stickers := globList(p.Config.Sticker)
|
||||||
audios := globList(trimElement(p.Config.Audio))
|
audios := globList(p.Config.Audio)
|
||||||
voices := globList(trimElement(p.Config.Voice))
|
voices := globList(p.Config.Voice)
|
||||||
videos := globList(trimElement(p.Config.Video))
|
videos := globList(p.Config.Video)
|
||||||
locations := trimElement(p.Config.Location)
|
locations := trimElement(p.Config.Location)
|
||||||
venues := trimElement(p.Config.Venue)
|
venues := trimElement(p.Config.Venue)
|
||||||
|
|
||||||
@@ -317,33 +346,47 @@ func (p Plugin) Exec() (err error) {
|
|||||||
if p.Config.Format == formatMarkdown {
|
if p.Config.Format == formatMarkdown {
|
||||||
message = escapeMarkdown(message)
|
message = escapeMarkdown(message)
|
||||||
|
|
||||||
p.Commit.Message = escapeMarkdownOne(p.Commit.Message)
|
escapeMarkdownFields(
|
||||||
p.Commit.Branch = escapeMarkdownOne(p.Commit.Branch)
|
&p.Commit.Message, &p.Commit.Branch, &p.Commit.Link,
|
||||||
p.Commit.Link = escapeMarkdownOne(p.Commit.Link)
|
&p.Commit.Author, &p.Commit.Email,
|
||||||
p.Commit.Author = escapeMarkdownOne(p.Commit.Author)
|
&p.Build.Tag, &p.Build.Link, &p.Build.PR,
|
||||||
p.Commit.Email = escapeMarkdownOne(p.Commit.Email)
|
&p.Repo.Namespace, &p.Repo.Name,
|
||||||
|
)
|
||||||
p.Build.Tag = escapeMarkdownOne(p.Build.Tag)
|
}
|
||||||
p.Build.Link = escapeMarkdownOne(p.Build.Link)
|
|
||||||
p.Build.PR = escapeMarkdownOne(p.Build.PR)
|
// pre-render message templates (identical for all users)
|
||||||
|
var renderedMessages []string
|
||||||
p.Repo.Namespace = escapeMarkdownOne(p.Repo.Namespace)
|
for _, value := range message {
|
||||||
p.Repo.Name = escapeMarkdownOne(p.Repo.Name)
|
txt, err := template.RenderTrim(value, p)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
renderedMessages = append(renderedMessages, html.UnescapeString(txt))
|
||||||
|
}
|
||||||
|
|
||||||
|
// pre-parse locations and venues (identical for all users)
|
||||||
|
var parsedLocations []Location
|
||||||
|
for _, value := range locations {
|
||||||
|
loc, empty := convertLocation(value)
|
||||||
|
if !empty {
|
||||||
|
parsedLocations = append(parsedLocations, loc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var parsedVenues []Location
|
||||||
|
for _, value := range venues {
|
||||||
|
loc, empty := convertLocation(value)
|
||||||
|
if !empty {
|
||||||
|
parsedVenues = append(parsedVenues, loc)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// send message.
|
|
||||||
for _, user := range ids {
|
for _, user := range ids {
|
||||||
for _, value := range message {
|
for _, txt := range renderedMessages {
|
||||||
txt, err := template.RenderTrim(value, p)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
txt = html.UnescapeString(txt)
|
|
||||||
|
|
||||||
msg := tgbotapi.NewMessage(user, txt)
|
msg := tgbotapi.NewMessage(user, txt)
|
||||||
msg.ParseMode = p.Config.Format
|
msg.ParseMode = p.Config.Format
|
||||||
msg.DisableWebPagePreview = !p.Config.WebPreview
|
msg.DisableWebPagePreview = p.Config.DisableWebPagePreview
|
||||||
|
msg.DisableNotification = p.Config.DisableNotification
|
||||||
if err := p.Send(bot, msg); err != nil {
|
if err := p.Send(bot, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -372,7 +415,7 @@ func (p Plugin) Exec() (err error) {
|
|||||||
|
|
||||||
for _, value := range audios {
|
for _, value := range audios {
|
||||||
msg := tgbotapi.NewAudioUpload(user, value)
|
msg := tgbotapi.NewAudioUpload(user, value)
|
||||||
msg.Title = "Audio Message."
|
msg.Title = "Audio Message"
|
||||||
if err := p.Send(bot, msg); err != nil {
|
if err := p.Send(bot, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -393,27 +436,21 @@ func (p Plugin) Exec() (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, value := range locations {
|
for _, loc := range parsedLocations {
|
||||||
location, empty := convertLocation(value)
|
msg := tgbotapi.NewLocation(user, loc.Latitude, loc.Longitude)
|
||||||
|
|
||||||
if empty {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
msg := tgbotapi.NewLocation(user, location.Latitude, location.Longitude)
|
|
||||||
if err := p.Send(bot, msg); err != nil {
|
if err := p.Send(bot, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, value := range venues {
|
for _, loc := range parsedVenues {
|
||||||
location, empty := convertLocation(value)
|
msg := tgbotapi.NewVenue(
|
||||||
|
user,
|
||||||
if empty {
|
loc.Title,
|
||||||
continue
|
loc.Address,
|
||||||
}
|
loc.Latitude,
|
||||||
|
loc.Longitude,
|
||||||
msg := tgbotapi.NewVenue(user, location.Title, location.Address, location.Latitude, location.Longitude)
|
)
|
||||||
if err := p.Send(bot, msg); err != nil {
|
if err := p.Send(bot, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -424,7 +461,7 @@ func (p Plugin) Exec() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send bot message.
|
// Send bot message.
|
||||||
func (p Plugin) Send(bot *tgbotapi.BotAPI, msg tgbotapi.Chattable) error {
|
func (p *Plugin) Send(bot *tgbotapi.BotAPI, msg tgbotapi.Chattable) error {
|
||||||
message, err := bot.Send(msg)
|
message, err := bot.Send(msg)
|
||||||
|
|
||||||
if p.Config.Debug {
|
if p.Config.Debug {
|
||||||
@@ -437,11 +474,11 @@ func (p Plugin) Send(bot *tgbotapi.BotAPI, msg tgbotapi.Chattable) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.New(strings.Replace(err.Error(), p.Config.Token, "<token>", -1))
|
return errors.New(strings.ReplaceAll(err.Error(), p.Config.Token, "<token>"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Message is plugin default message.
|
// Message is plugin default message.
|
||||||
func (p Plugin) Message() []string {
|
func (p *Plugin) Message() []string {
|
||||||
icon := icons[strings.ToLower(p.Build.Status)]
|
icon := icons[strings.ToLower(p.Build.Status)]
|
||||||
|
|
||||||
if p.Config.GitHub {
|
if p.Config.GitHub {
|
||||||
@@ -459,14 +496,16 @@ func (p Plugin) Message() []string {
|
|||||||
// chore: update default template
|
// chore: update default template
|
||||||
//
|
//
|
||||||
// 🌐 https://cloud.drone.io/appleboy/drone-telegram/106
|
// 🌐 https://cloud.drone.io/appleboy/drone-telegram/106
|
||||||
return []string{fmt.Sprintf("%s Build #%d of `%s` %s.\n\n📝 Commit by %s on `%s`:\n``` %s ```\n\n🌐 %s",
|
return []string{
|
||||||
icon,
|
fmt.Sprintf("%s Build #%d of `%s` %s.\n\n📝 Commit by %s on `%s`:\n``` %s ```\n\n🌐 %s",
|
||||||
p.Build.Number,
|
icon,
|
||||||
p.Repo.FullName,
|
p.Build.Number,
|
||||||
p.Build.Status,
|
p.Repo.FullName,
|
||||||
p.Commit.Author,
|
p.Build.Status,
|
||||||
p.Commit.Branch,
|
p.Commit.Author,
|
||||||
p.Commit.Message,
|
p.Commit.Branch,
|
||||||
p.Build.Link,
|
p.Commit.Message,
|
||||||
)}
|
p.Build.Link,
|
||||||
|
),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+185
-34
@@ -3,16 +3,26 @@ package main
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/appleboy/drone-template-lib/template"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func skipIfNoTelegramSecrets(t *testing.T) {
|
||||||
|
t.Helper()
|
||||||
|
if os.Getenv("TELEGRAM_TOKEN") == "" || os.Getenv("TELEGRAM_TO") == "" {
|
||||||
|
t.Skip("TELEGRAM_TOKEN/TELEGRAM_TO not set; skipping integration test")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestMissingDefaultConfig(t *testing.T) {
|
func TestMissingDefaultConfig(t *testing.T) {
|
||||||
var plugin Plugin
|
var plugin Plugin
|
||||||
|
|
||||||
err := plugin.Exec()
|
err := plugin.Exec()
|
||||||
|
|
||||||
assert.NotNil(t, err)
|
assert.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMissingUserConfig(t *testing.T) {
|
func TestMissingUserConfig(t *testing.T) {
|
||||||
@@ -24,7 +34,7 @@ func TestMissingUserConfig(t *testing.T) {
|
|||||||
|
|
||||||
err := plugin.Exec()
|
err := plugin.Exec()
|
||||||
|
|
||||||
assert.NotNil(t, err)
|
assert.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDefaultMessageFormat(t *testing.T) {
|
func TestDefaultMessageFormat(t *testing.T) {
|
||||||
@@ -49,7 +59,13 @@ func TestDefaultMessageFormat(t *testing.T) {
|
|||||||
|
|
||||||
message := plugin.Message()
|
message := plugin.Message()
|
||||||
|
|
||||||
assert.Equal(t, []string{"✅ Build #101 of `appleboy/go-hello` success.\n\n📝 Commit by Bo-Yi Wu on `master`:\n``` update travis ```\n\n🌐 https://github.com/appleboy/go-hello"}, message)
|
assert.Equal(
|
||||||
|
t,
|
||||||
|
[]string{
|
||||||
|
"✅ Build #101 of `appleboy/go-hello` success.\n\n📝 Commit by Bo-Yi Wu on `master`:\n``` update travis ```\n\n🌐 https://github.com/appleboy/go-hello",
|
||||||
|
},
|
||||||
|
message,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDefaultMessageFormatFromGitHub(t *testing.T) {
|
func TestDefaultMessageFormatFromGitHub(t *testing.T) {
|
||||||
@@ -71,7 +87,11 @@ func TestDefaultMessageFormatFromGitHub(t *testing.T) {
|
|||||||
|
|
||||||
message := plugin.Message()
|
message := plugin.Message()
|
||||||
|
|
||||||
assert.Equal(t, []string{"appleboy/go-hello/test-workflow triggered by appleboy (push)"}, message)
|
assert.Equal(
|
||||||
|
t,
|
||||||
|
[]string{"appleboy/go-hello/test-workflow triggered by appleboy (push)"},
|
||||||
|
message,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSendMessage(t *testing.T) {
|
func TestSendMessage(t *testing.T) {
|
||||||
@@ -95,8 +115,13 @@ func TestSendMessage(t *testing.T) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Config: Config{
|
Config: Config{
|
||||||
Token: os.Getenv("TELEGRAM_TOKEN"),
|
Token: os.Getenv("TELEGRAM_TOKEN"),
|
||||||
To: []string{os.Getenv("TELEGRAM_TO"), os.Getenv("TELEGRAM_TO") + ":appleboy@gmail.com", "中文ID", "1234567890"},
|
To: []string{
|
||||||
|
os.Getenv("TELEGRAM_TO"),
|
||||||
|
os.Getenv("TELEGRAM_TO") + ":appleboy@gmail.com",
|
||||||
|
"中文ID",
|
||||||
|
"1234567890",
|
||||||
|
},
|
||||||
Message: "Test Telegram Chat Bot From Travis or Local, commit message: 『{{ build.message }}』",
|
Message: "Test Telegram Chat Bot From Travis or Local, commit message: 『{{ build.message }}』",
|
||||||
Photo: []string{"tests/github.png", "1234", " "},
|
Photo: []string{"tests/github.png", "1234", " "},
|
||||||
Document: []string{"tests/gophercolor.png", "1234", " "},
|
Document: []string{"tests/gophercolor.png", "1234", " "},
|
||||||
@@ -104,24 +129,73 @@ func TestSendMessage(t *testing.T) {
|
|||||||
Audio: []string{"tests/audio.mp3", "1234", " "},
|
Audio: []string{"tests/audio.mp3", "1234", " "},
|
||||||
Voice: []string{"tests/voice.ogg", "1234", " "},
|
Voice: []string{"tests/voice.ogg", "1234", " "},
|
||||||
Location: []string{"24.9163213 121.1424972", "1", " "},
|
Location: []string{"24.9163213 121.1424972", "1", " "},
|
||||||
Venue: []string{"35.661777 139.704051 竹北體育館 新竹縣竹北市", "24.9163213 121.1424972", "1", " "},
|
Venue: []string{
|
||||||
Video: []string{"tests/video.mp4", "1234", " "},
|
"35.661777 139.704051 竹北體育館 新竹縣竹北市",
|
||||||
Debug: false,
|
"24.9163213 121.1424972",
|
||||||
|
"1",
|
||||||
|
" ",
|
||||||
|
},
|
||||||
|
Video: []string{"tests/video.mp4", "1234", " "},
|
||||||
|
Debug: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := plugin.Exec()
|
err := plugin.Exec()
|
||||||
assert.NotNil(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
plugin.Config.Format = formatMarkdown
|
plugin.Config.Format = formatMarkdown
|
||||||
plugin.Config.Message = "Test escape under_score"
|
plugin.Config.Message = "Test escape under_score"
|
||||||
err = plugin.Exec()
|
err = plugin.Exec()
|
||||||
assert.NotNil(t, err)
|
require.Error(t, err)
|
||||||
|
|
||||||
// disable message
|
// disable message
|
||||||
plugin.Config.Message = ""
|
plugin.Config.Message = ""
|
||||||
err = plugin.Exec()
|
err = plugin.Exec()
|
||||||
assert.NotNil(t, err)
|
assert.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDisableWebPagePreviewMessage(t *testing.T) {
|
||||||
|
skipIfNoTelegramSecrets(t)
|
||||||
|
plugin := Plugin{
|
||||||
|
Config: Config{
|
||||||
|
Token: os.Getenv("TELEGRAM_TOKEN"),
|
||||||
|
To: []string{os.Getenv("TELEGRAM_TO")},
|
||||||
|
DisableWebPagePreview: true,
|
||||||
|
Debug: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.Config.Message = "DisableWebPagePreview https://www.google.com.tw"
|
||||||
|
err := plugin.Exec()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// disable message
|
||||||
|
plugin.Config.DisableWebPagePreview = false
|
||||||
|
plugin.Config.Message = "EnableWebPagePreview https://www.google.com.tw"
|
||||||
|
err = plugin.Exec()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDisableNotificationMessage(t *testing.T) {
|
||||||
|
skipIfNoTelegramSecrets(t)
|
||||||
|
plugin := Plugin{
|
||||||
|
Config: Config{
|
||||||
|
Token: os.Getenv("TELEGRAM_TOKEN"),
|
||||||
|
To: []string{os.Getenv("TELEGRAM_TO")},
|
||||||
|
DisableNotification: true,
|
||||||
|
Debug: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.Config.Message = "DisableNotification https://www.google.com.tw"
|
||||||
|
err := plugin.Exec()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// disable message
|
||||||
|
plugin.Config.DisableNotification = false
|
||||||
|
plugin.Config.Message = "EnableNotification https://www.google.com.tw"
|
||||||
|
err = plugin.Exec()
|
||||||
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBotError(t *testing.T) {
|
func TestBotError(t *testing.T) {
|
||||||
@@ -150,7 +224,7 @@ func TestBotError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err := plugin.Exec()
|
err := plugin.Exec()
|
||||||
assert.NotNil(t, err)
|
assert.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTrimElement(t *testing.T) {
|
func TestTrimElement(t *testing.T) {
|
||||||
@@ -226,7 +300,7 @@ func TestParseTo(t *testing.T) {
|
|||||||
|
|
||||||
// test empty ids
|
// test empty ids
|
||||||
ids = parseTo([]string{"", " ", " "}, "a@gmail.com", true)
|
ids = parseTo([]string{"", " ", " "}, "a@gmail.com", true)
|
||||||
assert.Equal(t, 0, len(ids))
|
assert.Empty(t, ids)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGlobList(t *testing.T) {
|
func TestGlobList(t *testing.T) {
|
||||||
@@ -250,27 +324,27 @@ func TestConvertLocation(t *testing.T) {
|
|||||||
input = "1"
|
input = "1"
|
||||||
result, empty = convertLocation(input)
|
result, empty = convertLocation(input)
|
||||||
|
|
||||||
assert.Equal(t, true, empty)
|
assert.True(t, empty)
|
||||||
assert.Equal(t, Location{}, result)
|
assert.Equal(t, Location{}, result)
|
||||||
|
|
||||||
// strconv.ParseInt: parsing "測試": invalid syntax
|
// strconv.ParseInt: parsing "測試": invalid syntax
|
||||||
input = "測試 139.704051"
|
input = "測試 139.704051"
|
||||||
result, empty = convertLocation(input)
|
result, empty = convertLocation(input)
|
||||||
|
|
||||||
assert.Equal(t, true, empty)
|
assert.True(t, empty)
|
||||||
assert.Equal(t, Location{}, result)
|
assert.Equal(t, Location{}, result)
|
||||||
|
|
||||||
// strconv.ParseInt: parsing "測試": invalid syntax
|
// strconv.ParseInt: parsing "測試": invalid syntax
|
||||||
input = "35.661777 測試"
|
input = "35.661777 測試"
|
||||||
result, empty = convertLocation(input)
|
result, empty = convertLocation(input)
|
||||||
|
|
||||||
assert.Equal(t, true, empty)
|
assert.True(t, empty)
|
||||||
assert.Equal(t, Location{}, result)
|
assert.Equal(t, Location{}, result)
|
||||||
|
|
||||||
input = "35.661777 139.704051"
|
input = "35.661777 139.704051"
|
||||||
result, empty = convertLocation(input)
|
result, empty = convertLocation(input)
|
||||||
|
|
||||||
assert.Equal(t, false, empty)
|
assert.False(t, empty)
|
||||||
assert.Equal(t, Location{
|
assert.Equal(t, Location{
|
||||||
Latitude: float64(35.661777),
|
Latitude: float64(35.661777),
|
||||||
Longitude: float64(139.704051),
|
Longitude: float64(139.704051),
|
||||||
@@ -279,7 +353,7 @@ func TestConvertLocation(t *testing.T) {
|
|||||||
input = "35.661777 139.704051 title"
|
input = "35.661777 139.704051 title"
|
||||||
result, empty = convertLocation(input)
|
result, empty = convertLocation(input)
|
||||||
|
|
||||||
assert.Equal(t, false, empty)
|
assert.False(t, empty)
|
||||||
assert.Equal(t, Location{
|
assert.Equal(t, Location{
|
||||||
Title: "title",
|
Title: "title",
|
||||||
Address: "",
|
Address: "",
|
||||||
@@ -290,7 +364,7 @@ func TestConvertLocation(t *testing.T) {
|
|||||||
input = "35.661777 139.704051 title address"
|
input = "35.661777 139.704051 title address"
|
||||||
result, empty = convertLocation(input)
|
result, empty = convertLocation(input)
|
||||||
|
|
||||||
assert.Equal(t, false, empty)
|
assert.False(t, empty)
|
||||||
assert.Equal(t, Location{
|
assert.Equal(t, Location{
|
||||||
Title: "title",
|
Title: "title",
|
||||||
Address: "address",
|
Address: "address",
|
||||||
@@ -300,6 +374,7 @@ func TestConvertLocation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHTMLMessage(t *testing.T) {
|
func TestHTMLMessage(t *testing.T) {
|
||||||
|
skipIfNoTelegramSecrets(t)
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Repo: Repo{
|
Repo: Repo{
|
||||||
Name: "go-hello",
|
Name: "go-hello",
|
||||||
@@ -309,7 +384,7 @@ func TestHTMLMessage(t *testing.T) {
|
|||||||
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||||
Author: "Bo-Yi Wu",
|
Author: "Bo-Yi Wu",
|
||||||
Branch: "master",
|
Branch: "master",
|
||||||
Message: "Freakin' macOS isn't fully case-sensitive..",
|
Message: "test",
|
||||||
},
|
},
|
||||||
Build: Build{
|
Build: Build{
|
||||||
Number: 101,
|
Number: 101,
|
||||||
@@ -320,14 +395,24 @@ func TestHTMLMessage(t *testing.T) {
|
|||||||
Config: Config{
|
Config: Config{
|
||||||
Token: os.Getenv("TELEGRAM_TOKEN"),
|
Token: os.Getenv("TELEGRAM_TOKEN"),
|
||||||
To: []string{os.Getenv("TELEGRAM_TO")},
|
To: []string{os.Getenv("TELEGRAM_TO")},
|
||||||
|
Message: `
|
||||||
|
Test HTML Format
|
||||||
|
<a href='https://google.com'>Google .com 1</a>
|
||||||
|
<a href='https://google.com'>Google .com 2</a>
|
||||||
|
<a href='https://google.com'>Google .com 3</a>
|
||||||
|
`,
|
||||||
|
Format: formatHTML,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := plugin.Exec()
|
assert.NoError(t, plugin.Exec())
|
||||||
assert.Nil(t, err)
|
|
||||||
|
plugin.Config.MessageFile = "tests/message_html.txt"
|
||||||
|
assert.NoError(t, plugin.Exec())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMessageFile(t *testing.T) {
|
func TestMessageFile(t *testing.T) {
|
||||||
|
skipIfNoTelegramSecrets(t)
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Repo: Repo{
|
Repo: Repo{
|
||||||
Name: "go-hello",
|
Name: "go-hello",
|
||||||
@@ -340,9 +425,11 @@ func TestMessageFile(t *testing.T) {
|
|||||||
Message: "Freakin' macOS isn't fully case-sensitive..",
|
Message: "Freakin' macOS isn't fully case-sensitive..",
|
||||||
},
|
},
|
||||||
Build: Build{
|
Build: Build{
|
||||||
Number: 101,
|
Number: 101,
|
||||||
Status: "success",
|
Status: "success",
|
||||||
Link: "https://github.com/appleboy/go-hello",
|
Link: "https://github.com/appleboy/go-hello",
|
||||||
|
Started: time.Now().Unix(),
|
||||||
|
Finished: time.Now().Add(180 * time.Second).Unix(),
|
||||||
},
|
},
|
||||||
|
|
||||||
Config: Config{
|
Config: Config{
|
||||||
@@ -353,10 +440,45 @@ func TestMessageFile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err := plugin.Exec()
|
err := plugin.Exec()
|
||||||
assert.Nil(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTemplateVars(t *testing.T) {
|
func TestTemplateVars(t *testing.T) {
|
||||||
|
skipIfNoTelegramSecrets(t)
|
||||||
|
plugin := Plugin{
|
||||||
|
Repo: Repo{
|
||||||
|
Name: "go-hello",
|
||||||
|
Namespace: "appleboy",
|
||||||
|
},
|
||||||
|
Commit: Commit{
|
||||||
|
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||||
|
Author: "Bo-Yi Wu",
|
||||||
|
Branch: "master",
|
||||||
|
Message: "This is a test commit msg",
|
||||||
|
},
|
||||||
|
Build: Build{
|
||||||
|
Number: 101,
|
||||||
|
Status: "success",
|
||||||
|
Link: "https://github.com/appleboy/go-hello",
|
||||||
|
Started: time.Now().Unix(),
|
||||||
|
Finished: time.Now().Add(180 * time.Second).Unix(),
|
||||||
|
},
|
||||||
|
|
||||||
|
Config: Config{
|
||||||
|
Token: os.Getenv("TELEGRAM_TOKEN"),
|
||||||
|
To: []string{os.Getenv("TELEGRAM_TO")},
|
||||||
|
Format: formatMarkdown,
|
||||||
|
MessageFile: "tests/message_template.txt",
|
||||||
|
TemplateVars: `{"env":"testing","version":"1.2.0-SNAPSHOT"}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
err := plugin.Exec()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTemplateVarsFile(t *testing.T) {
|
||||||
|
skipIfNoTelegramSecrets(t)
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Repo: Repo{
|
Repo: Repo{
|
||||||
Name: "go-hello",
|
Name: "go-hello",
|
||||||
@@ -375,19 +497,20 @@ func TestTemplateVars(t *testing.T) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
Config: Config{
|
Config: Config{
|
||||||
Token: os.Getenv("TELEGRAM_TOKEN"),
|
Token: os.Getenv("TELEGRAM_TOKEN"),
|
||||||
To: []string{os.Getenv("TELEGRAM_TO")},
|
To: []string{os.Getenv("TELEGRAM_TO")},
|
||||||
Format: formatMarkdown,
|
Format: formatMarkdown,
|
||||||
MessageFile: "tests/message_template.txt",
|
MessageFile: "tests/message_template.txt",
|
||||||
TemplateVars: `{"env":"testing","version":"1.2.0-SNAPSHOT"}`,
|
TemplateVarsFile: "tests/vars.json",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := plugin.Exec()
|
err := plugin.Exec()
|
||||||
assert.Nil(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProxySendMessage(t *testing.T) {
|
func TestProxySendMessage(t *testing.T) {
|
||||||
|
skipIfNoTelegramSecrets(t)
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Repo: Repo{
|
Repo: Repo{
|
||||||
Name: "go-hello",
|
Name: "go-hello",
|
||||||
@@ -417,5 +540,33 @@ func TestProxySendMessage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err := plugin.Exec()
|
err := plugin.Exec()
|
||||||
assert.Nil(t, err)
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBuildTemplate(t *testing.T) {
|
||||||
|
plugin := Plugin{
|
||||||
|
Commit: Commit{
|
||||||
|
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||||
|
Author: "Bo-Yi Wu",
|
||||||
|
Branch: "master",
|
||||||
|
Message: "This is a test commit msg",
|
||||||
|
},
|
||||||
|
Build: Build{
|
||||||
|
Number: 101,
|
||||||
|
Status: "success",
|
||||||
|
Link: "https://github.com/appleboy/go-hello",
|
||||||
|
Started: time.Now().Unix(),
|
||||||
|
Finished: time.Now().Add(180 * time.Second).Unix(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := template.RenderTrim(
|
||||||
|
`
|
||||||
|
Sample message loaded from file.
|
||||||
|
|
||||||
|
Commit msg: {{uppercasefirst commit.message}}
|
||||||
|
|
||||||
|
duration: {{duration build.started build.finished}}
|
||||||
|
`, plugin)
|
||||||
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ Sample message loaded from file.
|
|||||||
|
|
||||||
Commit msg: {{commit.message}}
|
Commit msg: {{commit.message}}
|
||||||
|
|
||||||
|
duration: {{duration build.started build.finished}}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Test HTML Format from file
|
||||||
|
<a href='https://google.com'>Google .com 1</a>
|
||||||
|
<a href='https://google.com'>Google .com 2</a>
|
||||||
|
<a href='https://google.com'>Google .com 3</a>
|
||||||
|
<a href='https://google.com'>Google .com 4</a>
|
||||||
@@ -5,3 +5,4 @@ Sample message template loaded from file.
|
|||||||
|
|
||||||
Commit msg: {{commit.message}}
|
Commit msg: {{commit.message}}
|
||||||
|
|
||||||
|
duration: {{duration build.started build.finished}}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
{"env":"testing","version":"1.2.0-SNAPSHOT"}
|
||||||
Reference in New Issue
Block a user