-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
58 lines (57 loc) · 3.1 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: 'Idobata Notify'
description: 'Send actions notification to Idobata'
inputs:
idobata_hook_url: # url of input
description: 'Idobata Custom Webhook URL'
required: true
default: ''
status: # Status of previous job
description: 'Get previous job status'
required: false
default: ${{ job.status }}
runs:
using: "composite"
steps:
- name: 👤 Get commit info for notification
run: |
echo 'COMMIT_ACTOR=${{ github.actor }}' | awk -F '-preview' '{print $1}' >> $GITHUB_ENV
if [ "${{ inputs.status }}" = "success" ]; then
echo "STATUS_LABEL=success" >> $GITHUB_ENV
echo "STATUS_TEXT=Success" >> $GITHUB_ENV
echo "STATUS_VERB=passed" >> $GITHUB_ENV
elif [ "${{ inputs.status }}" = "skipped" ]; then
echo "STATUS_LABEL=default" >> $GITHUB_ENV
echo "STATUS_TEXT=Skip" >> $GITHUB_ENV
echo "STATUS_VERB=skipped" >> $GITHUB_ENV
else
echo "STATUS_LABEL=danger" >> $GITHUB_ENV
echo "STATUS_TEXT=Failure" >> $GITHUB_ENV
echo "STATUS_VERB=failed" >> $GITHUB_ENV
fi
if [ "${{ github.event_name }}" = "pull_request" ]; then
head_sha=$(echo "${{ github.event.pull_request.head.sha }}" | head -c8)
echo "COMMIT_SHA=$head_sha" >> $GITHUB_ENV
echo "COMMIT_MESSAGE<<EOF" >> $GITHUB_ENV
echo "${{ github.event.pull_request.title }}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "COMMIT_URL=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV
echo "COMMIT_LINK=${{github.repository}}#${{github.event.pull_request.number}}" >> $GITHUB_ENV
else
head_sha=$(echo "${{ github.sha }}" | head -c8)
echo "COMMIT_SHA=$head_sha" >> $GITHUB_ENV
echo "COMMIT_MESSAGE<<EOF" >> $GITHUB_ENV
echo "${{ github.event.head_commit.message }}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "COMMIT_URL=https://github.com/${{github.repository}}/commit/$head_sha" >> $GITHUB_ENV
echo "COMMIT_LINK=${{ github.repository }}#$head_sha" >> $GITHUB_ENV
fi
shell: bash
- name: 🔔 Notify results to Idobata
env:
IDOBATA_SECRETS: ${{ inputs.idobata_hook_url }}
uses: mahaker/actions-idobata@v1.1.2
with:
hookUrl: ${{ env.IDOBATA_SECRETS }}
format: 'markdown'
message: |
Your tests ${{ env.STATUS_VERB }} on [${{ env.COMMIT_LINK }}](${{ env.COMMIT_URL }}) ([build](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})) : <span class='label label-${{ env.STATUS_LABEL }}'>${{ env.STATUS_TEXT }}</span><br><img src='https://github.com/${{ env.COMMIT_ACTOR }}.png' class='icon-rounded' width='16' height='16'> [${{ env.COMMIT_ACTOR }}](https://github.com/${{ env.COMMIT_ACTOR }}): ${{ env.COMMIT_MESSAGE }} ([${{ env.COMMIT_SHA }}](https://github.com/${{ github.repository }}/commit/${{ env.COMMIT_SHA }}))