A simple way to accomplish two common tasks in Drone CI: caching and notifications.
drone-helper notify
is essentially a convenience wrapper over shoutrrr.
All it does is gather the relevant build info from Drone, arrange it into a rich text message in a format supported by the respective platform and send it.
- name: notify
image: zoickx/drone-helper
commands:
- drone-helper notify --discord
settings:
discord_webhook_token:
# ex. value: hcXPnPGg_w6ZCPF-4OkLMn7nyTxEbZKex2R2suPNyUTWVl89ij9Qd46DosbREhnykUm4
from_secret: discord_token
discord_webhook_id:
# ex value: 1125469839924488938
from_secret: discord_id
- name: notify
image: zoickx/drone-helper
commands:
- drone-helper notify --slack
settings:
slack_webhook_token:
# ex. value: T15S51XNJSJ-B05T0LOP280-n8zDEin7EmijY0iCuaISBDay
from_secret: discord_token
drone-helper cache
implements full-system caching via Docker (a practice endorsed by the developer).
A cache is uniquely identified by its build dependencies (--deps
), and will be rebuilt if any one changes.
drone-helper cache
must be run before any steps using the cache (even if cache exists and doesn't need rebuilding).- The repository must be "Trusted" in Drone (Settings -> General -> Project Settings -> Trusted)
- The step invoking
drone-helper cache
must mount the host'sdocker.sock
. - Subsequent steps that need to use the cache must be run in exactly:
image: cache--${DRONE_REPO}:${DRONE_COMMIT_AFTER}
pull: never
---
kind: pipeline
type: docker
name: default
volumes:
- name: dockersock
host:
path: /var/run/docker.sock
steps:
- name: rebuild-cache
image: zoickx/drone-helper
commands:
- drone-helper cache --deps="Dockerfile dependencies.json"
volumes:
- name: dockersock
path: /var/run/docker.sock
- name: run-in-cache-1
image: cache--${DRONE_REPO}:${DRONE_COMMIT_AFTER}
pull: never
commands:
- echo "This command will be run in cache. [1]"
- name: run-in-cache-2
image: cache--${DRONE_REPO}:${DRONE_COMMIT_AFTER}
pull: never
commands:
- echo "This command will be run in cache. [2]"
- name: notify
image: zoickx/drone-helper
commands:
- drone-helper notify --discord
settings:
discord_webhook_token:
from_secret: discord_token
discord_webhook_id:
from_secret: discord_id