forked from Mergifyio/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcf-build.sh
executable file
·49 lines (43 loc) · 1.41 KB
/
cf-build.sh
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
#!/bin/bash
set -e
set -o pipefail
slack_message () {
local message="$1"
local filename="docs-build-${CF_PAGES_COMMIT_SHA}.log"
local payload=$(
cat <<SLACK_EOF
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${message}"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Cloudflare log",
"emoji": true
},
"url": "https://dash.cloudflare.com/799c85a11fd788c9c914fa97c52d971e/pages/view/docs-cf-prod"
}
}
]
}
SLACK_EOF
)
echo -en "$payload" | curl -s -H "Content-type: application/json" -d @- "$SLACK_DEPLOYMENT_WEBHOOK_URL_RELEASES"
if [ "$conclusion" == "failure" ]; then
echo -en "$payload" | curl -s -H "Content-type: application/json" -d @- "$SLACK_DEPLOYMENT_WEBHOOK_URL_PROD"
curl -F [email protected] -F "initial_comment=$filename" -F channels=CJBEQQPFG -H "Authorization: Bearer $SLACK_DEPLOYMENT_BOT_TOKEN" https://slack.com/api/files.upload
fi
}
echo "Starting build..." > build.log
slack_message "*Building (${CF_PAGES_BRANCH}/${CF_PAGES_COMMIT_SHA}) of docs *"
exit() { slack_message "*Deployment (${CF_PAGES_BRANCH}/${CF_PAGES_COMMIT_SHA}) of docs finished ${emoji}*\\\nConclusion: ${conclusion}"; }
conclusion="failure" emoji="💥"
trap exit EXIT
gatsby build 2>&1 | tee -a build.log
conclusion="success" emoji="🦾"