action_ntfy/action.yml

37 lines
1.4 KiB
YAML

name: 'Build notification'
description: 'Send build notification over ntfy.sh'
inputs:
topic:
description: 'ntfy.sh topic'
required: true
default: ''
token:
description: 'ntfy.sh token'
required: true
default: ''
jobstatus:
description: 'Job status'
required: true
default: ''
runs:
using: "composite"
steps:
- name: Shorten SHA
id: shorten-sha
shell: bash
env:
FULLSHA: "${{ format('{0}', github.sha) }}"
run: echo "shortsha=[${FULLSHA:0:8}]" >> $GITHUB_OUTPUT
- name: Send notification
shell: bash
env:
NTFYMSG: ${{ (startsWith(github.ref, 'refs/tags/') && format('Tag {0} created', github.ref_name) || format('{0} {1}', steps.shorten-sha.outputs.shortsha, github.event.head_commit.message)) }}
NTFYTAGS: "${{ format('Tags: {0},{1}', inputs.jobstatus == 'success' && 'white_check_mark' || 'x', github.ref_name) }}"
NTFYTITLE: "${{ format('Title: {0} - Build {1} {2}', github.repository, github.run_number, inputs.jobstatus) }}"
NTFYICON: "${{ format('Icon: {0}', github.event.repository.avatar_url) }}"
NTFYURL: "${{ format('https://ntfy.sh/{0}', inputs.topic) }}"
NTFYTOKEN: "${{ format('Authorization: Bearer {0}', inputs.token) }}"
run: 'curl -s -o /dev/null -H "$NTFYTAGS" -H "$NTFYTITLE" -H "$NTFYICON" -H "$NTFYTOKEN" -d "$NTFYMSG" $NTFYURL'