diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..811071e --- /dev/null +++ b/.drone.yml @@ -0,0 +1,203 @@ +--- +kind: pipeline +name: dockerhub-build-trigger + +platform: + os: linux + arch: amd64 + +clone: + disable: true + +trigger: + branch: + - master + event: + - push + - cron + target: + exclude: + - nightly + status: + - success + - failure + +steps: +- name: call webhook + pull: always + image: bash:latest + environment: + ENDPOINT: + from_secret: dockerhub_endpoint + commands: + - apk add --no-cache curl + - curl -sO https://git.dotya.ml/wanderer/${DRONE_REPO}/raw/branch/master/curl.it + - bash ./curl.it $ENDPOINT + + +--- +kind: pipeline +name: dockerhub-build-trigger-nightly + +platform: + os: linux + arch: amd64 + +clone: + disable: true + +trigger: + event: + - cron + cron: + - nightly + status: + - success + - failure + +steps: +- name: call webhook + pull: always + image: bash:latest + environment: + ENDPOINT: + from_secret: dockerhub_endpoint_nightly + commands: + - apk add --no-cache curl + - curl -sO https://git.dotya.ml/wanderer/${DRONE_REPO}/raw/branch/master/curl.it + - bash ./curl.it -n $ENDPOINT + + +--- +kind: pipeline +name: notifications + +platform: + os: linux + arch: amd64 + +clone: + disable: true + +trigger: + branch: + - master + event: + - push + - tag + status: + - success + - failure + +depends_on: + - dockerhub-build-trigger + +steps: + - name: discord + pull: always + image: appleboy/drone-discord:1.2.4 + settings: + message: > + {{#success build.status}} + ✅ [Build #{{build.number}}]({{build.link}}) of `{{repo.name}}` succeeded. + event: **`{{build.event}}`** + commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}` + ```{{commit.message}}``` + {{else}} + ❌ [Build #{{build.number}}]({{build.link}}) of `{{repo.name}}` failed. + event: **`${DRONE_BUILD_EVENT}`** + commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}` + ```{{commit.message}}``` + {{/success}} + webhook_id: + from_secret: discord_webhook_id + webhook_token: + from_secret: discord_webhook_token + +--- +kind: pipeline +name: notifications-cronbuild + +platform: + os: linux + arch: amd64 + +clone: + disable: true + +trigger: + event: + - cron + cron: + - hourly + - hourly-build + status: + - success + - failure + +depends_on: + - dockerhub-build-trigger + +steps: + - name: discord + pull: always + image: appleboy/drone-discord:1.2.4 + settings: + message: > + {{#success build.status}} + ✅ [Cron build #{{build.number}}]({{build.link}}) of `{{repo.name}}` succeeded. + event: **`{{build.event}}`** + commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}` + {{else}} + ❌ [Cron build #{{build.number}}]({{build.link}}) of `{{repo.name}}` failed. + event: **`${DRONE_BUILD_EVENT}`** + commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}` + {{/success}} + webhook_id: + from_secret: discord_webhook_hourly_id + webhook_token: + from_secret: discord_webhook_hourly_token + username: drone-hourly + +--- +kind: pipeline +name: notifications-cronbuild-nightly + +platform: + os: linux + arch: amd64 + +clone: + disable: true + +trigger: + event: + - cron + cron: + - nightly + status: + - success + - failure + +depends_on: + - dockerhub-build-trigger-nightly + +steps: + - name: discord + pull: always + image: appleboy/drone-discord:1.2.4 + settings: + message: > + {{#success build.status}} + ✅ [Cron build #{{build.number}}]({{build.link}}) of `{{repo.name}}` succeeded. + event: **`{{build.event}}`** + commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}` + {{else}} + ❌ [Cron build #{{build.number}}]({{build.link}}) of `{{repo.name}}` failed.\nevent: **`${DRONE_BUILD_EVENT}`** + commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}` + {{/success}} + webhook_id: + from_secret: discord_webhook_hourly_id + webhook_token: + from_secret: discord_webhook_hourly_token + username: drone-nightly diff --git a/curl.it b/curl.it new file mode 100755 index 0000000..bd2b744 --- /dev/null +++ b/curl.it @@ -0,0 +1,7 @@ +#!/bin/bash + +if [ $# -gt 1 ]; then + curl -s -H 'Content-Type: application/json' --data '{"docker_tag":"nightly"}' -X POST $2 +else + curl -s -H 'Content-Type: application/json' --data '{"docker_tag":"latest"}' -X POST $1 +fi