Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
|
beae931f9b | ||
|
636bbdd2f0 | ||
|
ad429d0e00 | ||
|
b4557bb67a | ||
cb7e4bde7a |
11 changed files with 3 additions and 202 deletions
|
@ -1,7 +0,0 @@
|
|||
FROM badouralix/curl-jq:latest
|
||||
|
||||
COPY repo//check /opt/resource/check
|
||||
COPY repo/in /opt/resource/in
|
||||
COPY repo//out /opt/resource/out
|
||||
|
||||
RUN chmod +x /opt/resource/out /opt/resource/in /opt/resource/check
|
40
README.md
40
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.
|
||||
|
|
20
check
20
check
|
@ -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
|
|
@ -1 +0,0 @@
|
|||
`fly -t home set-pipeline -l secrets.yml -l vars.yml -p concourse-apprise-notifier -c pipeline.yml`
|
12
example.json
12
example.json
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"params": {
|
||||
"body": "hoi",
|
||||
"title": "Titeltje!",
|
||||
"type": "warning",
|
||||
"format": "text"
|
||||
},
|
||||
"source": {
|
||||
"key": "concourse",
|
||||
"host": "https://apprise.pim.kunis.nl:444"
|
||||
}
|
||||
}
|
19
in
19
in
|
@ -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
|
9
labels
9
labels
|
@ -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=
|
49
out
49
out
|
@ -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 <<EOF
|
||||
{
|
||||
"body": ${alert_body},
|
||||
"title": ${alert_title},
|
||||
"type": ${alert_type},
|
||||
"tag": ${alert_tag},
|
||||
"format": ${alert_format}
|
||||
}
|
||||
EOF
|
||||
)"
|
||||
|
||||
compact_body="$(echo "${body}" | jq -c '.')"
|
||||
echo "$compact_body" | jq 'del(..|nulls)' > /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
|
46
pipeline.yml
46
pipeline.yml
|
@ -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
|
1
vars.yml
1
vars.yml
|
@ -1 +0,0 @@
|
|||
image_version: "1.1"
|
1
version
Normal file
1
version
Normal file
|
@ -0,0 +1 @@
|
|||
1.1.4
|
Loading…
Reference in a new issue