Compare commits

...

12 commits
v0.2.0 ... main

Author SHA1 Message Date
Bruno BELANYI 31b3b9fd24 flake: bump version to v0.4.0
All checks were successful
ci/woodpecker/push/check Pipeline was successful
2024-01-03 15:55:45 +00:00
Bruno BELANYI 37491e91e6 matrix-notifier: fix link to pipeline 2024-01-03 15:55:45 +00:00
Bruno BELANYI 48dad0c962 ci: use more explicit step name
All checks were successful
ci/woodpecker/push/check Pipeline was successful
2023-11-18 20:22:30 +00:00
Bruno BELANYI a57f1cfa71 ci: add package check 2023-11-18 20:22:30 +00:00
Bruno BELANYI d30a2d7366 ci: remove deprecated syntax 2023-11-18 20:22:30 +00:00
Bruno BELANYI 436483aac7 ci: remove Drone CI
All checks were successful
ci/woodpecker/push/check Pipeline was successful
ci/woodpecker/manual/check Pipeline was successful
2023-04-14 16:07:37 +00:00
Bruno BELANYI cb62f179a3 ci: add Woodpecker CI workflow 2023-04-14 16:07:37 +00:00
Bruno BELANYI 04758f81f2 flake: bump version to v0.3.0
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-18 12:48:28 +00:00
Bruno BELANYI eebe509b02 matrix-notifier: add woodpecker integration
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-18 12:46:36 +00:00
Bruno BELANYI 0bc11d85d5 nix: fix flake description 2023-03-18 12:42:02 +00:00
Bruno BELANYI 007994e0a2 nix: migrate from deprecated attributes
All checks were successful
continuous-integration/drone/push Build is passing
2022-06-03 16:30:12 +02:00
Bruno BELANYI b6a9c7e6a4 nix: use 'inputsFrom'
All checks were successful
continuous-integration/drone/push Build is passing
2021-10-08 15:49:05 +02:00
4 changed files with 64 additions and 44 deletions

View file

@ -1,27 +0,0 @@
---
kind: pipeline
type: exec
name: Matrix Notifier check
steps:
- name: Pre-commit checks
commands:
- nix flake check
- name: Notifiy
commands:
- nix run .
environment:
ADDRESS:
from_secret: matrix_homeserver
ROOM:
from_secret: matrix_roomid
USER:
from_secret: matrix_username
PASS:
from_secret: matrix_password
when:
status:
- failure
- success
...

31
.woodpecker/check.yml Normal file
View file

@ -0,0 +1,31 @@
labels:
type: exec
steps:
- name: flake check
image: bash
commands:
- nix flake check
- name: package check
image: bash
commands:
- nix build
- name: notifiy
image: bash
secrets:
- source: matrix_password
target: pass
- source: matrix_homeserver
target: address
- source: matrix_roomid
target: room
- source: matrix_username
target: user
commands:
- nix run .
when:
status:
- failure
- success

View file

@ -1,5 +1,5 @@
{
description = "Ambroisie's blog";
description = "A simple Matrix notifier for CI purposes";
inputs = {
futils = {
@ -36,6 +36,8 @@
in
rec {
apps = {
default = apps.matrix-notifier;
matrix-notifier =
futils.lib.mkApp { drv = packages.matrix-notifier; };
};
@ -56,26 +58,24 @@
};
};
defaultApp = apps.matrix-notifier;
devShells = {
default = pkgs.mkShell {
name = "matrix-notifier";
defaultPackage = packages.matrix-notifier;
inputsFrom = with self.packages.${system}; [
matrix-notifier
];
devShell = pkgs.mkShell {
name = "matrix-notifier";
buildInputs = with pkgs; [
curl
jq
shellcheck
];
inherit (self.checks.${system}.pre-commit) shellHook;
inherit (self.checks.${system}.pre-commit) shellHook;
};
};
packages = {
default = packages.matrix-notifier;
matrix-notifier = pkgs.stdenvNoCC.mkDerivation rec {
pname = "matrix-notifier";
version = "0.2.0";
version = "0.4.0";
src = ./matrix-notifier;

View file

@ -16,7 +16,7 @@ usage() {
print_err " which message type should be sent must be one of"
print_err " 'text' or 'notice', or 'auto'."
print_err " The special value 'auto' defaults to 'notice', unless"
print_err " 'DRONE_BUILD_STATUS' indicates a failure."
print_err " 'CI_PIPELINE_STATUS'/'DRONE_BUILD_STATUS' indicates a failure."
}
# Blessed Stack Overflow
@ -38,6 +38,18 @@ rawurlencode() {
echo "$encoded")
}
default_woodpecker_message() {
local msg="Build ${CI_PIPELINE_STATUS}"
local woodpecker_url="${CI_PIPELINE_URL}"
if [ "$FORMAT" == "true" ]; then
msg="$msg [${CI_REPO}#${CI_COMMIT_SHA:0:8}]($woodpecker_url)"
else
msg="$msg $woodpecker_url"
fi
msg="$msg (${CI_COMMIT_TAG:-$CI_COMMIT_BRANCH})"
printf '%s' "$msg"
}
default_drone_message() {
local msg="Build ${DRONE_BUILD_STATUS}"
local drone_url="${DRONE_SYSTEM_PROTO}://${DRONE_SYSTEM_HOST}/${DRONE_REPO}/${DRONE_BUILD_NUMBER}"
@ -51,7 +63,9 @@ default_drone_message() {
}
ensure_variables() {
if [ "$DRONE" == "true" ] && [ -z "$MESSAGE" ]; then
if [ "$CI" == "woodpecker" ] && [ -z "$MESSAGE" ]; then
MESSAGE="$(default_woodpecker_message)"
elif [ "$DRONE" == "true" ] && [ -z "$MESSAGE" ]; then
MESSAGE="$(default_drone_message)"
fi
@ -69,7 +83,9 @@ ensure_variables() {
get_message_type() {
if [ "$MSG_TYPE" == "auto" ]; then
if [ "$DRONE_BUILD_STATUS" == "failure" ]; then
if [ "$CI_PIPELINE_STATUS" == "failure" ]; then
MSG_TYPE="text"
elif [ "$DRONE_BUILD_STATUS" == "failure" ]; then
MSG_TYPE="text"
else
MSG_TYPE="notice"