File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ # Copyright Broadcom, Inc. All Rights Reserved.
2+ # SPDX-License-Identifier: APACHE-2.0
3+
4+ name : ' GChat Notification'
5+ on :
6+ workflow_call :
7+ inputs :
8+ workflow :
9+ type : string
10+ required : true
11+ job-url :
12+ type : string
13+ required : true
14+ repository :
15+ type : string
16+ secrets :
17+ webhook-url :
18+ required : true
19+ # Remove all permissions by default
20+ permissions : {}
21+ jobs :
22+ notification :
23+ name : Google Chat Notification
24+ runs-on : ubuntu-latest
25+ steps :
26+ - name : Notify
27+ env :
28+ JOB_URL : ${{ inputs.job-url }}
29+ GH_WORKFLOW : ${{ inputs.workflow }}
30+ GH_REPOSITORY : ${{ inputs.repository != '' && inputs.repository || github.repository }}
31+ WEBHOOK_URL : ${{ secrets.webhook-url }}
32+ run : |
33+ tmp_file=$(mktemp)
34+ cat >"${tmp_file}"<<EOF
35+ ⚠️ [${GH_REPOSITORY}] Failure detected on '${GH_WORKFLOW}' workflow ⚠️
36+ 📑 See details <${JOB_URL}|here>.
37+ EOF
38+
39+ # Use curl to send the JSON to Google.
40+ escapedText=$(sed -e 's/\n/\\n/g' -e 's/"/\\"/g' -e "s/'/\\'/g" "${tmp_file}")
41+ json="{\"text\": \"$escapedText\"}"
42+ curl -o /tmp/out -s --fail -X POST -H 'Content-Type: application/json' -d "$json" "${WEBHOOK_URL}"
You can’t perform that action at this time.
0 commit comments