commit ad19ea1b63350a3af92d087a41b54ef012a69b8c Author: fuse314 Date: Thu Nov 7 21:15:34 2024 +0000 add ntfy.sh action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..41a5a78 --- /dev/null +++ b/action.yml @@ -0,0 +1,36 @@ +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: ${{ 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: "Tags: ${{ inputs.jobstatus == 'success' && 'white_check_mark' || 'x' }}" + NTFYTITLE: "Title: ${{ github.repository }} - Build # ${{ github.run_number }} ${{ inputs.jobstatus }}" + NTFYICON: "Icon: ${{ github.event.repository.avatar_url }}" + NTFYURL: "https://ntfy.sh/${{ inputs.topic }}" + NTFYTOKEN: "Authorization: Bearer ${{ inputs.token }}" + run: 'curl -s -o /dev/null -H "$NTFYTAGS" -H "$NTFYTITLE" -H "$NTFYICON" -H "$NTFYTOKEN" -d "$NTFYMSG" $NTFYURL'