forked from graphql/graphql-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.sh
executable file
·51 lines (43 loc) · 1.3 KB
/
publish.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
#!/bin/bash -e
# This script publishes the GraphQL specification document to the web.
# Build the specification document into publishable form
echo "Building spec"
npm run build > /dev/null 2>&1
# Determine if this is a tagged release
GITTAG=$(git tag --points-at HEAD)
# Check out gh-pages locally.
echo "Cloning gh-pages"
rm -rf gh-pages
git clone -b gh-pages "https://${GH_TOKEN}@github.com/facebook/graphql.git" gh-pages > /dev/null 2>&1
pushd gh-pages > /dev/null 2>&1
# Replace /draft with this build.
echo "Publishing to: /draft"
rm -rf draft
cp -r ../out/ draft
# If this is a tagged commit, publish to a permalink and index.
if [ -n "$GITTAG" ]; then
echo "Publishing to: /$GITTAG"
cp -r ../out/ "$GITTAG"
echo "Linking from: / (index)"
echo '<html>
<head>
<meta http-equiv="refresh" content="0; url=./'"$GITTAG"'" />
<title>GraphQL Specification</title>
</head>
<body>
Redirecting to the latest release: <a href="./'"$GITTAG"'">'"$GITTAG"'</a>
</body>
</html>' > index.html
fi
echo "Pushing update"
git config user.name "Travis CI"
git config user.email "[email protected]"
git add -A .
if git diff --staged --quiet; then
echo "Nothing to publish"
else
git diff --quiet git commit -a -m "Deploy to GitHub Pages"
git push > /dev/null 2>&1
echo "Pushed"
fi
popd > /dev/null 2>&1