fix drone yaml format and switch to drone-matrix plugin (#6)

* fix drone yaml format and switch to drone-matrix plugin

* fix matrix notification template
This commit is contained in:
Robert Kaussow 2021-09-19 20:42:12 +02:00 committed by GitHub
parent 3fd2dfdafa
commit 8f126adc7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 475 additions and 418 deletions

View File

@ -361,11 +361,11 @@ local PipelineNotifications = {
}, },
{ {
name: 'matrix', name: 'matrix',
image: 'plugins/matrix', image: 'thegeeklab/drone-matrix',
settings: { settings: {
homeserver: { from_secret: 'matrix_homeserver' }, homeserver: { from_secret: 'matrix_homeserver' },
roomid: { from_secret: 'matrix_roomid' }, roomid: { from_secret: 'matrix_roomid' },
template: 'Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}', template: 'Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}) ({{ build.Branch }}) by {{ commit.Author }}<br/> Message: {{ commit.Message }}',
username: { from_secret: 'matrix_username' }, username: { from_secret: 'matrix_username' },
password: { from_secret: 'matrix_password' }, password: { from_secret: 'matrix_password' },
}, },

View File

@ -1,477 +1,534 @@
--- ---
image_pull_secrets:
- docker_config
kind: pipeline kind: pipeline
name: test name: test
platform: platform:
arch: amd64
os: linux os: linux
arch: amd64
steps: steps:
- commands: - name: staticcheck
- go run honnef.co/go/tools/cmd/staticcheck ./... image: golang:1.16
image: golang:1.16 commands:
name: staticcheck - go run honnef.co/go/tools/cmd/staticcheck ./...
volumes: volumes:
- name: gopath
path: /go
- name: lint
image: golang:1.16
commands:
- go run golang.org/x/lint/golint -set_exit_status ./...
volumes:
- name: gopath
path: /go
- name: vet
image: golang:1.16
commands:
- go vet ./...
volumes:
- name: gopath
path: /go
- name: test
image: golang:1.16
commands:
- go test -cover ./...
volumes:
- name: gopath
path: /go
volumes:
- name: gopath - name: gopath
path: /go temp: {}
- commands:
- go run golang.org/x/lint/golint -set_exit_status ./... image_pull_secrets:
image: golang:1.16 - docker_config
name: lint
volumes:
- name: gopath
path: /go
- commands:
- go vet ./...
image: golang:1.16
name: vet
volumes:
- name: gopath
path: /go
- commands:
- go test -cover ./...
image: golang:1.16
name: test
volumes:
- name: gopath
path: /go
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
volumes:
- name: gopath
temp: {}
--- ---
depends_on:
- test
image_pull_secrets:
- docker_config
kind: pipeline kind: pipeline
name: build-binaries name: build-binaries
platform: platform:
arch: amd64
os: linux os: linux
arch: amd64
steps: steps:
- commands: - name: build
- '[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}' image: techknowlogick/xgo:go-1.16.x
- mkdir -p release/ commands:
- cd cmd/drone-matrix && xgo -ldflags "-s -w -X main.version=$BUILD_VERSION" -tags - "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-matrix - mkdir -p release/
. - cd cmd/drone-matrix && xgo -ldflags "-s -w -X main.version=$BUILD_VERSION" -tags netgo -targets 'linux/amd64,linux/arm-6,linux/arm-7,linux/arm64' -out drone-matrix .
- mv /build/* /drone/src/release/ - mv /build/* /drone/src/release/
- ls -l /drone/src/release/ - ls -l /drone/src/release/
image: techknowlogick/xgo:go-1.16.x
name: build - name: executable
- commands: image: alpine
- $(find release/ -executable -type f | grep drone-matrix-linux-amd64) --help commands:
image: alpine - $(find release/ -executable -type f | grep drone-matrix-linux-amd64) --help
name: executable
- commands: - name: compress
- apk add upx image: alpine
- find release/ -maxdepth 1 -executable -type f -exec upx {} \; commands:
- ls -lh release/ - apk add upx
image: alpine - find release/ -maxdepth 1 -executable -type f -exec upx {} \;
name: compress - ls -lh release/
- commands:
- cd release/ && sha256sum * > sha256sum.txt - name: checksum
image: alpine image: alpine
name: checksum commands:
- commands: - cd release/ && sha256sum * > sha256sum.txt
- git fetch -tq
- git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased - name: changelog-generate
unreleased} image: thegeeklab/git-chglog
image: thegeeklab/git-chglog commands:
name: changelog-generate - git fetch -tq
- commands: - git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}
- prettier CHANGELOG.md
- prettier -w CHANGELOG.md - name: changelog-format
image: thegeeklab/alpine-tools image: thegeeklab/alpine-tools
name: changelog-format commands:
- image: plugins/github-release - prettier CHANGELOG.md
name: publish - prettier -w CHANGELOG.md
settings:
api_key: - name: publish
from_secret: github_token image: plugins/github-release
files: settings:
- release/* api_key:
note: CHANGELOG.md from_secret: github_token
overwrite: true files:
title: ${DRONE_TAG} - release/*
when: note: CHANGELOG.md
ref: overwrite: true
- refs/tags/** title: ${DRONE_TAG}
when:
ref:
- refs/tags/**
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
---
depends_on: depends_on:
- test - test
image_pull_secrets:
- docker_config ---
kind: pipeline kind: pipeline
name: build-container-amd64 name: build-container-amd64
platform: platform:
arch: amd64
os: linux os: linux
arch: amd64
steps: steps:
- commands: - name: build
- '[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}' image: golang:1.16
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/amd64/drone-matrix commands:
./cmd/drone-matrix - "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
image: golang:1.16 - go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/amd64/drone-matrix ./cmd/drone-matrix
name: build
- depends_on: - name: dryrun
- build image: thegeeklab/drone-docker:19
image: thegeeklab/drone-docker:19 settings:
name: dryrun config:
settings: from_secret: docker_config
config: dockerfile: docker/Dockerfile.amd64
from_secret: docker_config dry_run: true
dockerfile: docker/Dockerfile.amd64 password:
dry_run: true from_secret: docker_password
password: repo: thegeeklab/${DRONE_REPO_NAME}
from_secret: docker_password username:
repo: thegeeklab/${DRONE_REPO_NAME} from_secret: docker_username
username: when:
from_secret: docker_username ref:
when: - refs/pull/**
ref: depends_on:
- refs/pull/** - build
- depends_on:
- dryrun - name: publish-dockerhub
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
name: publish-dockerhub settings:
settings: auto_tag: true
auto_tag: true auto_tag_suffix: amd64
auto_tag_suffix: amd64 config:
config: from_secret: docker_config
from_secret: docker_config dockerfile: docker/Dockerfile.amd64
dockerfile: docker/Dockerfile.amd64 password:
password: from_secret: docker_password
from_secret: docker_password repo: thegeeklab/${DRONE_REPO_NAME}
repo: thegeeklab/${DRONE_REPO_NAME} username:
username: from_secret: docker_username
from_secret: docker_username when:
when: ref:
ref: - refs/heads/main
- refs/heads/main - refs/tags/**
- refs/tags/** depends_on:
- depends_on: - dryrun
- dryrun
image: thegeeklab/drone-docker:19 - name: publish-quay
name: publish-quay image: thegeeklab/drone-docker:19
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: amd64 auto_tag_suffix: amd64
config: config:
from_secret: docker_config from_secret: docker_config
dockerfile: docker/Dockerfile.amd64 dockerfile: docker/Dockerfile.amd64
password: password:
from_secret: quay_password from_secret: quay_password
registry: quay.io registry: quay.io
repo: quay.io/thegeeklab/${DRONE_REPO_NAME} repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
username: username:
from_secret: quay_username from_secret: quay_username
when: when:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
depends_on:
- dryrun
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
---
depends_on: depends_on:
- test - test
image_pull_secrets:
- docker_config ---
kind: pipeline kind: pipeline
name: build-container-arm64 name: build-container-arm64
platform: platform:
arch: arm64
os: linux os: linux
arch: arm64
steps: steps:
- commands: - name: build
- '[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}' image: golang:1.16
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm64/drone-matrix commands:
./cmd/drone-matrix - "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
image: golang:1.16 - go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm64/drone-matrix ./cmd/drone-matrix
name: build
- depends_on: - name: dryrun
- build image: thegeeklab/drone-docker:19
image: thegeeklab/drone-docker:19 settings:
name: dryrun config:
settings: from_secret: docker_config
config: dockerfile: docker/Dockerfile.arm64
from_secret: docker_config dry_run: true
dockerfile: docker/Dockerfile.arm64 password:
dry_run: true from_secret: docker_password
password: repo: thegeeklab/${DRONE_REPO_NAME}
from_secret: docker_password username:
repo: thegeeklab/${DRONE_REPO_NAME} from_secret: docker_username
username: when:
from_secret: docker_username ref:
when: - refs/pull/**
ref: depends_on:
- refs/pull/** - build
- depends_on:
- dryrun - name: publish-dockerhub
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
name: publish-dockerhub settings:
settings: auto_tag: true
auto_tag: true auto_tag_suffix: arm64
auto_tag_suffix: arm64 config:
config: from_secret: docker_config
from_secret: docker_config dockerfile: docker/Dockerfile.arm64
dockerfile: docker/Dockerfile.arm64 password:
password: from_secret: docker_password
from_secret: docker_password repo: thegeeklab/${DRONE_REPO_NAME}
repo: thegeeklab/${DRONE_REPO_NAME} username:
username: from_secret: docker_username
from_secret: docker_username when:
when: ref:
ref: - refs/heads/main
- refs/heads/main - refs/tags/**
- refs/tags/** depends_on:
- depends_on: - dryrun
- dryrun
image: thegeeklab/drone-docker:19 - name: publish-quay
name: publish-quay image: thegeeklab/drone-docker:19
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: arm64 auto_tag_suffix: arm64
config: config:
from_secret: docker_config from_secret: docker_config
dockerfile: docker/Dockerfile.arm64 dockerfile: docker/Dockerfile.arm64
password: password:
from_secret: quay_password from_secret: quay_password
registry: quay.io registry: quay.io
repo: quay.io/thegeeklab/${DRONE_REPO_NAME} repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
username: username:
from_secret: quay_username from_secret: quay_username
when: when:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
depends_on:
- dryrun
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
---
depends_on: depends_on:
- test - test
image_pull_secrets:
- docker_config ---
kind: pipeline kind: pipeline
name: build-container-arm name: build-container-arm
platform: platform:
arch: arm
os: linux os: linux
arch: arm
steps: steps:
- commands: - name: build
- '[ -z "${DRONE_TAG}" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}' image: golang:1.16
- go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm/drone-matrix commands:
./cmd/drone-matrix - "[ -z \"${DRONE_TAG}\" ] && BUILD_VERSION=${DRONE_COMMIT_SHA:0:8} || BUILD_VERSION=${DRONE_TAG##v}"
image: golang:1.16 - go build -v -ldflags "-X main.version=$BUILD_VERSION" -a -tags netgo -o release/arm/drone-matrix ./cmd/drone-matrix
name: build
- depends_on: - name: dryrun
- build image: thegeeklab/drone-docker:19
image: thegeeklab/drone-docker:19 settings:
name: dryrun config:
settings: from_secret: docker_config
config: dockerfile: docker/Dockerfile.arm
from_secret: docker_config dry_run: true
dockerfile: docker/Dockerfile.arm password:
dry_run: true from_secret: docker_password
password: repo: thegeeklab/${DRONE_REPO_NAME}
from_secret: docker_password username:
repo: thegeeklab/${DRONE_REPO_NAME} from_secret: docker_username
username: when:
from_secret: docker_username ref:
when: - refs/pull/**
ref: depends_on:
- refs/pull/** - build
- depends_on:
- dryrun - name: publish-dockerhub
image: thegeeklab/drone-docker:19 image: thegeeklab/drone-docker:19
name: publish-dockerhub settings:
settings: auto_tag: true
auto_tag: true auto_tag_suffix: arm
auto_tag_suffix: arm config:
config: from_secret: docker_config
from_secret: docker_config dockerfile: docker/Dockerfile.arm
dockerfile: docker/Dockerfile.arm password:
password: from_secret: docker_password
from_secret: docker_password repo: thegeeklab/${DRONE_REPO_NAME}
repo: thegeeklab/${DRONE_REPO_NAME} username:
username: from_secret: docker_username
from_secret: docker_username when:
when: ref:
ref: - refs/heads/main
- refs/heads/main - refs/tags/**
- refs/tags/** depends_on:
- depends_on: - dryrun
- dryrun
image: thegeeklab/drone-docker:19 - name: publish-quay
name: publish-quay image: thegeeklab/drone-docker:19
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: arm auto_tag_suffix: arm
config: config:
from_secret: docker_config from_secret: docker_config
dockerfile: docker/Dockerfile.arm dockerfile: docker/Dockerfile.arm
password: password:
from_secret: quay_password from_secret: quay_password
registry: quay.io registry: quay.io
repo: quay.io/thegeeklab/${DRONE_REPO_NAME} repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
username: username:
from_secret: quay_username from_secret: quay_username
when: when:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
depends_on:
- dryrun
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
---
concurrency:
limit: 1
depends_on: depends_on:
- build-binaries - test
- build-container-amd64
- build-container-arm64 ---
- build-container-arm
kind: pipeline kind: pipeline
name: docs name: docs
platform: platform:
arch: amd64
os: linux os: linux
arch: amd64
concurrency:
limit: 1
steps: steps:
- commands: - name: markdownlint
- markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md' image: thegeeklab/markdownlint-cli
image: thegeeklab/markdownlint-cli commands:
name: markdownlint - markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md'
- commands:
- npm install -g spellchecker-cli - name: spellcheck
- spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary image: node:lts-alpine
-p spell indefinite-article syntax-urls --no-suggestions commands:
environment: - npm install -g spellchecker-cli
FORCE_COLOR: true - spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions
NPM_CONFIG_LOGLEVEL: error environment:
image: node:lts-alpine FORCE_COLOR: true
name: spellcheck NPM_CONFIG_LOGLEVEL: error
- image: plugins/gh-pages
name: publish - name: publish
settings: image: plugins/gh-pages
pages_directory: _docs/ settings:
password: pages_directory: _docs/
from_secret: github_token password:
target_branch: docs from_secret: github_token
username: target_branch: docs
from_secret: github_username username:
when: from_secret: github_username
ref: when:
- refs/heads/main ref:
- refs/heads/main
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
- refs/pull/** - refs/pull/**
---
depends_on: depends_on:
- docs - build-binaries
image_pull_secrets: - build-container-amd64
- docker_config - build-container-arm64
- build-container-arm
---
kind: pipeline kind: pipeline
name: notifications name: notifications
platform: platform:
arch: amd64
os: linux os: linux
arch: amd64
steps: steps:
- image: plugins/manifest - name: manifest-dockerhub
name: manifest-dockerhub image: plugins/manifest
settings: settings:
auto_tag: true auto_tag: true
ignore_missing: true ignore_missing: true
password: password:
from_secret: docker_password from_secret: docker_password
spec: docker/manifest.tmpl spec: docker/manifest.tmpl
username: username:
from_secret: docker_username from_secret: docker_username
when: when:
status: status:
- success - success
- image: plugins/manifest
name: manifest-quay - name: manifest-quay
settings: image: plugins/manifest
auto_tag: true settings:
ignore_missing: true auto_tag: true
password: ignore_missing: true
from_secret: quay_password password:
spec: docker/manifest-quay.tmpl from_secret: quay_password
username: spec: docker/manifest-quay.tmpl
from_secret: quay_username username:
when: from_secret: quay_username
status: when:
- success status:
- environment: - success
DOCKER_PASS:
from_secret: docker_password - name: pushrm-dockerhub
DOCKER_USER: image: chko/docker-pushrm:1
from_secret: docker_username environment:
PUSHRM_FILE: README.md DOCKER_PASS:
PUSHRM_SHORT: Drone plugin to to send messages to Matrix from_secret: docker_password
PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME} DOCKER_USER:
image: chko/docker-pushrm:1 from_secret: docker_username
name: pushrm-dockerhub PUSHRM_FILE: README.md
when: PUSHRM_SHORT: Drone plugin to to send messages to Matrix
status: PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME}
- success when:
- environment: status:
APIKEY__QUAY_IO: - success
from_secret: quay_token
PUSHRM_FILE: README.md - name: pushrm-quay
PUSHRM_TARGET: quay.io/thegeeklab/${DRONE_REPO_NAME} image: chko/docker-pushrm:1
image: chko/docker-pushrm:1 environment:
name: pushrm-quay APIKEY__QUAY_IO:
when: from_secret: quay_token
status: PUSHRM_FILE: README.md
- success PUSHRM_TARGET: quay.io/thegeeklab/${DRONE_REPO_NAME}
- image: plugins/matrix when:
name: matrix status:
settings: - success
homeserver:
from_secret: matrix_homeserver - name: matrix
password: image: thegeeklab/drone-matrix
from_secret: matrix_password settings:
roomid: homeserver:
from_secret: matrix_roomid from_secret: matrix_homeserver
template: 'Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name password:
}}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: from_secret: matrix_password
{{ build.message }}' roomid:
username: from_secret: matrix_roomid
from_secret: matrix_username template: "Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}) ({{ build.Branch }}) by {{ commit.Author }}<br/> Message: {{ commit.Message }}"
when: username:
status: from_secret: matrix_username
- success when:
- failure status:
- success
- failure
image_pull_secrets:
- docker_config
trigger: trigger:
ref: ref:
- refs/heads/main - refs/heads/main
- refs/tags/** - refs/tags/**
status: status:
- success - success
- failure - failure
depends_on:
- docs
--- ---
kind: signature kind: signature
hmac: 2a628319305f254a9f63d020eb220a5154b770c0da48a8c33ab944df476abade hmac: 187e914ad618a0d2d770ffaf2438889bb98bb6eb2c65559347afcbc95744ae4b
... ...

View File

@ -45,7 +45,7 @@ docker run --rm \
-e PLUGIN_PASSWORD=p455w0rd \ -e PLUGIN_PASSWORD=p455w0rd \
-v $(pwd):$(pwd) \ -v $(pwd):$(pwd) \
-w $(pwd) \ -w $(pwd) \
plugins/matrix thegeeklab/drone-matrix
``` ```
### Parameters ### Parameters