From 0013ef30a4c152d1dfdb556c7ee8002b2e01a1c5 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Wed, 14 Jun 2023 22:01:48 +0200 Subject: [PATCH] init --- README.md | 40 ++-------------------------------------- check | 20 -------------------- deploy.md | 1 - example.json | 12 ------------ in | 19 ------------------- labels | 9 --------- out | 49 ------------------------------------------------- pipeline.yml | 46 ---------------------------------------------- vars.yml | 1 - 9 files changed, 2 insertions(+), 195 deletions(-) delete mode 100755 check delete mode 100644 deploy.md delete mode 100644 example.json delete mode 100755 in delete mode 100644 labels delete mode 100755 out delete mode 100644 pipeline.yml delete mode 100644 vars.yml diff --git a/README.md b/README.md index 83f7a6a..05e32e9 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,3 @@ -# concourse-apprise-notifier +# project version -[Concourse](https://concourse-ci.org/) resource type to send [Apprise](https://github.com/caronc/apprise) notifications. -Code based on [github.com/mockersf/concourse-slack-notifier](https://github.com/mockersf/concourse-slack-notifier). -Currently, only the [persistent storage solution](https://github.com/caronc/apprise-api#persistent-storage-solution) is supported (because that's what I use). - -## Installing - -Add the following to our Concourse pipeline: -```yaml -resource_types: -- name: apprise - type: registry-image - source: - repository: git.pim.kunis.nl/pim/concourse-apprise-notifier -``` - -## Source Configuration - -- `host`: _Required_. Base Apprise host URL. -- `key`: _Required_. Notification key. - -## Behaviour - -`check`: No operation. - -`in`: No operation. - -`out`: Send a message via Apprise. - -### Parameters - -Check the official [Apprise documation](https://github.com/caronc/apprise-api#persistent-storage-solution) for more information. - -- `body`: _Required_. The body of the notification. -- `title`: The title of the notification. -- `type`: The type of the notification. -- `tag`: The tags of the notification. -- `format`: The format of the notification. +This branch tracks the version of the project's image for concourse. diff --git a/check b/check deleted file mode 100755 index d1390bb..0000000 --- a/check +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -set -e - -exec 3>&1 # make stdout available as fd 3 for the result -exec 1>&2 # redirect all output to stderr for logging - -PAYLOAD=$(mktemp /tmp/resource-check.XXXXXX) - -cat > "$PAYLOAD" <&0 - -TS=$(jq '.version.timestamp // empty' < "$PAYLOAD") - -if [ -z "$TS" ]; then - echo '[]' >&3 -else - jq -n "[ - { timestamp: $TS } - ]" >&3 -fi diff --git a/deploy.md b/deploy.md deleted file mode 100644 index a6c1518..0000000 --- a/deploy.md +++ /dev/null @@ -1 +0,0 @@ -`fly -t home set-pipeline -l secrets.yml -l vars.yml -p concourse-apprise-notifier -c pipeline.yml` diff --git a/example.json b/example.json deleted file mode 100644 index 6044786..0000000 --- a/example.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "params": { - "body": "hoi", - "title": "Titeltje!", - "type": "warning", - "format": "text" - }, - "source": { - "key": "concourse", - "host": "https://apprise.pim.kunis.nl:444" - } -} diff --git a/in b/in deleted file mode 100755 index 533c0ea..0000000 --- a/in +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -set -e - -exec 3>&1 # make stdout available as fd 3 for the result -exec 1>&2 # redirect all output to stderr for logging - -PAYLOAD=$(mktemp /tmp/resource-in.XXXXXX) - -cat > "$PAYLOAD" <&0 - -TS=$(jq '.version.timestamp // empty' < "$PAYLOAD") -[ -z "$TS" ] && TS='"none"' - -jq -n "{ - version: { - timestamp: $TS - } -}" >&3 diff --git a/labels b/labels deleted file mode 100644 index 7d6a089..0000000 --- a/labels +++ /dev/null @@ -1,9 +0,0 @@ -org.opencontainers.image.authors=Pim Kunis -org.opencontainers.image.source=https://git.pim.kunis.nl/pim/concourse-apprise-notifier/ -org.opencontainers.image.documentation=https://git.pim.kunis.nl/pim/concourse-apprise-notifier/src/branch/master/README.md -org.opencontainers.image.description=Concourse resource type to send Apprise notifications. -com.github.actions.run_url= -com.github.actions.run_id= -com.github.actions.job= -com.github.actions.event_name= -org.opencontainers.image.revision= diff --git a/out b/out deleted file mode 100755 index bbb3540..0000000 --- a/out +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# https://github.com/cloudfoundry-community/slack-notification-resource/blob/master/out -# https://github.com/caronc/apprise-api#persistent-storage-solution -set -e - -cd "${1}" - -timestamp="$(jq -n "{version:{timestamp:\"$(date +%s)\"}}")" - -exec 3>&1 -exec 1>&2 - -payload=$(mktemp /tmp/resource-in.XXXXXX) -cat > "${payload}" <&0 - -apprise_host="$(jq -r '.source.host' < "${payload}")" -apprise_key="$(jq -r '.source.key' < "${payload}")" - -alert_body="$(jq -r '.params.body' < "${payload}")" -alert_title="$(jq -r '.params.title // null' < "${payload}")" -alert_type="$(jq -r '.params.type // null' < "${payload}")" -alert_tag="$(jq -r '.params.tag // null' < "${payload}")" -alert_format="$(jq -r '.params.format // null' < "${payload}")" - -echo "${alert_body}" - -alert_body="$(eval "printf \"${alert_body}\"" | jq -R -s .)" -[ "${alert_title}" != "null" ] && alert_title="$(eval "printf \"${alert_title}\"" | jq -R -s .)" -[ "${alert_type}" != "null" ] && alert_type="$(eval "printf \"${alert_type}\"" | jq -R -s .)" -[ "${alert_tag}" != "null" ] && alert_tag="$(eval "printf \"${alert_tag}\"" | jq -R -s .)" -[ "${alert_format}" != "null" ] && alert_format="$(eval "printf \"${alert_format}\"" | jq -R -s .)" - -body="$(cat < /tmp/compact_body.json - -curl -v -X POST -T /tmp/compact_body.json -H "Content-Type: application/json" "${apprise_host}/notify/${apprise_key}" - -echo "${timestamp}" >&3 diff --git a/pipeline.yml b/pipeline.yml deleted file mode 100644 index 803d8c8..0000000 --- a/pipeline.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -resources: - - name: repo - type: git - source: - uri: https://git.pim.kunis.nl/pim/concourse-apprise-notifier.git - icon: git - - name: registry-image - type: registry-image - source: - repository: git.pim.kunis.nl/pim/concourse-apprise-notifier - username: pim - password: ((api_key)) - tag: ((image_version)) - icon: docker - -jobs: - - name: build-and-publish-image - plan: - - get: repo - trigger: true - - task: build-image - privileged: true - config: - platform: linux - image_resource: - type: registry-image - source: - repository: concourse/oci-build-task - inputs: - - name: repo - outputs: - - name: image - params: - DOCKERFILE: repo/Dockerfile - LABELS_FILE: repo/labels - run: - path: sh - args: - - -exc - - | - build - ls image - - put: registry-image - params: - image: image/image.tar diff --git a/vars.yml b/vars.yml deleted file mode 100644 index 5ae52dd..0000000 --- a/vars.yml +++ /dev/null @@ -1 +0,0 @@ -image_version: "1.1"