forked from prisma/prisma1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-docs.sh
executable file
·67 lines (57 loc) · 2.22 KB
/
deploy-docs.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
set -e
set -o pipefail
if [[ $CIRCLE_COMPARE_URL ]]; then
export lastCommits=`echo $CIRCLE_COMPARE_URL | sed -n 's/.*compare\/\(.*\)/\1/p' | sed 's/\.\.\./ /'`
else
export lastCommits="HEAD"
fi
export changedFiles=$(git diff-tree --no-commit-id --name-only -r $lastCommits)
if [[ "$changedFiles" = *"docs/1.0/"* ]] || \
[[ "$changedFiles" = *"docs/1.1/"* ]] || \
[[ "$changedFiles" = *"docs/1.2/"* ]] || \
[[ "$changedFiles" = *"docs/1.3/"* ]] || \
[[ "$changedFiles" = *"docs/1.4/"* ]] || \
[[ "$changedFiles" = *"docs/1.5/"* ]] || \
[[ "$changedFiles" = *"docs/1.6/"* ]] || \
[[ "$changedFiles" = *"docs/1.7/"* ]] || \
[[ "$changedFiles" = *"docs/1.8/"* ]] || \
[[ "$changedFiles" = *"docs/1.9/"* ]] || \
[[ "$changedFiles" = *"docs/1.10/"* ]] || \
[[ "$changedFiles" = *"docs/1.11/"* ]] || \
[[ "$changedFiles" = *"docs/1.12/"* ]] || \
[[ "$changedFiles" = *"docs/1.13/"* ]] || \
[[ "$changedFiles" = *"docs/1.14/"* ]];
then
echo "There were changes in the old docs. Going to deploy old docs"
if [ ! -z "$CIRCLE_BRANCH" ]; then
UPPER_BRANCH="MASTER"
PAT_GREEN_FROM_BRANCH="PAT_GREEN_${UPPER_BRANCH}"
PAT_GREEN=${!PAT_GREEN_FROM_BRANCH:?$PAT_GREEN_FROM_BRANCH env var not set}
PAT_BLUE_FROM_BRANCH="PAT_BLUE_${UPPER_BRANCH}"
PAT_BLUE=${!PAT_BLUE_FROM_BRANCH:?$PAT_BLUE_FROM_BRANCH env var not set}
fi
BRANCH="${CIRCLE_BRANCH:-dev}"
export PAT_BLUE="${PAT_BLUE:?PAT_BLUE env variable not set}"
export PAT_GREEN="${PAT_GREEN:?PAT_GREEN env variable not set}"
export BLUE_ID="${BLUE_ID:?BLUE_ID env variable not set}"
export GREEN_ID="${GREEN_ID:?GREEN_ID env variable not set}"
export SYSTEM_AUTH_TOKEN="${SYSTEM_AUTH_TOKEN:?SYSTEM_AUTH_TOKEN env variable not set}"
docs-cli -c ./docs
curl -X POST -d '' $NETLIFY_HOOK
elif [[ "$changedFiles" = *"docs/"* ]]; then
echo "Deploying new docs"
curl -H "Authorization: Bearer $BUILDKITE_TOKEN" -X POST "https://api.buildkite.com/v2/organizations/prisma/pipelines/prisma-docs/builds" \
-d '{
"commit": "HEAD",
"branch": "master",
"message": "Build trigger from content",
"author": {
"name": "Nikolas Burk",
"email": "burk@prisma.io"
}
}'
else
echo "No Changes. Exiting"
exit 0
fi