forked from dojo/widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·44 lines (36 loc) · 1.68 KB
/
deploy.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
#!/bin/bash
cp ./now.json ./output/dist
cp ./now.json ./output/dev
name="dojo.widgets"
if [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then
nowurl=$(npx now ./output/dist --token=$PUBLIC_NOW_TOKEN --public --name=$name --confirm)
if [ "$nowurl" = "" ] ; then
echo "Now deployment failed"
exit 1
fi
echo "* Docs Deployment: $nowurl" &>> deployments.txt
nowurl=$(npx now ./output/dev --token=$PUBLIC_NOW_TOKEN --public --name=$name --confirm)
if [ "$nowurl" = "" ] ; then
echo "Now deployment failed"
exit 1
fi
echo "* Tests Deployment: $nowurl" &>> deployments.txt
else
if [ "$TRAVIS_BRANCH" = "master" ] ; then
nowurl=$(npx now ./output/dist --token=$NOW_TOKEN --public --name=$name --scope=dojo --target=production --confirm)
if [ "$nowurl" = "" ] ; then
echo "Now deployment failed"
exit 1
fi
echo "Deployed to $nowurl"
if [ "$1" = "" ] ; then
deploymenturl=$(curl -H "Authorization: Bearer $GITHUB_TOKEN" -H "Content-Type: application/vnd.github.v3+json" -s -X POST https://api.github.com/repos/$TRAVIS_REPO_SLUG/deployments -d '{"ref": "'$TRAVIS_COMMIT'","environment": "production","description": "Deploy request from Travis","auto_merge":false,"required_contexts":[]}' | jq -r '.url')
if [ "$deploymenturl" = "null" ] ; then
echo "Failed creating github deployment"
exit 1
fi
echo "Github deployment url $deploymenturl"
curl -H "Authorization: Bearer $GITHUB_TOKEN" -H "Content-Type: application/vnd.github.v3+json" -s -X POST $deploymenturl/statuses -d '{"environment": "production", "state": "success", "target_url": "'$nowurl'", "log_url": "'$nowurl'/_logs", "environment_url": "'$nowurl'", "description": "Deployment finished successfully."}'
fi
fi
fi