2017-02-06 14:56:54 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Publish material2 docs assets to the material2-docs-content repo
|
|
|
|
|
# material.angular.io will pull from this assets repo to get the latest docs
|
|
|
|
|
|
2017-06-29 19:32:00 +02:00
|
|
|
# The script should immediately exit if any command in the script fails.
|
|
|
|
|
set -e
|
|
|
|
|
|
2017-02-06 14:56:54 -05:00
|
|
|
cd "$(dirname $0)/../../"
|
|
|
|
|
|
2017-07-05 19:30:34 +02:00
|
|
|
if [ -z ${MATERIAL2_DOCS_CONTENT_TOKEN} ]; then
|
|
|
|
|
echo "Error: No access token for GitHub could be found." \
|
|
|
|
|
"Please set the environment variable 'MATERIAL2_DOCS_CONTENT_TOKEN'."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2017-02-16 18:41:42 -05:00
|
|
|
docsPath="./dist/docs"
|
2017-04-12 17:40:31 -07:00
|
|
|
packagePath="./dist/releases/material-examples"
|
2017-02-06 14:56:54 -05:00
|
|
|
repoPath="/tmp/material2-docs-content"
|
2017-03-09 14:00:31 -08:00
|
|
|
repoUrl="https://github.com/angular/material2-docs-content"
|
2017-02-16 18:41:42 -05:00
|
|
|
examplesSource="./dist/docs/examples"
|
2017-02-06 14:56:54 -05:00
|
|
|
|
2017-05-22 23:58:32 +02:00
|
|
|
if [[ ! ${*} == *--no-build* ]]; then
|
|
|
|
|
$(npm bin)/gulp material-examples:build-release:clean
|
|
|
|
|
$(npm bin)/gulp docs
|
|
|
|
|
fi
|
2017-02-06 14:56:54 -05:00
|
|
|
|
|
|
|
|
# Get git meta info for commit
|
|
|
|
|
commitSha="$(git rev-parse --short HEAD)"
|
|
|
|
|
commitAuthorName="$(git --no-pager show -s --format='%an' HEAD)"
|
|
|
|
|
commitAuthorEmail="$(git --no-pager show -s --format='%ae' HEAD)"
|
|
|
|
|
commitMessage="$(git log --oneline -n 1)"
|
|
|
|
|
|
|
|
|
|
# create directory and clone test repo
|
2017-02-16 18:41:42 -05:00
|
|
|
rm -rf $repoPath
|
2017-02-10 16:36:50 -05:00
|
|
|
mkdir -p $repoPath
|
2017-06-15 22:31:15 +02:00
|
|
|
git clone $repoUrl $repoPath --depth 1
|
2017-02-06 14:56:54 -05:00
|
|
|
|
|
|
|
|
# Clean out repo directory and copy contents of dist/docs into it
|
|
|
|
|
rm -rf $repoPath/*
|
2017-04-12 17:40:31 -07:00
|
|
|
|
|
|
|
|
# Create folders that will contain docs content files.
|
|
|
|
|
mkdir $repoPath/{overview,guides,api,examples,plunker,examples-package}
|
2017-02-06 14:56:54 -05:00
|
|
|
|
2017-04-10 09:52:19 -06:00
|
|
|
# Copy api files over to $repoPath/api
|
2017-02-06 14:56:54 -05:00
|
|
|
cp -r $docsPath/api/* $repoPath/api
|
|
|
|
|
|
2017-04-12 17:40:31 -07:00
|
|
|
# Copy the material-examples package to the docs content repository.
|
|
|
|
|
cp -r $packagePath/* $repoPath/examples-package
|
|
|
|
|
|
2017-02-06 14:56:54 -05:00
|
|
|
# Flatten the markdown docs structure and move it into $repoPath/overview
|
|
|
|
|
overviewFiles=$docsPath/markdown/
|
|
|
|
|
for filename in $overviewFiles*
|
|
|
|
|
do
|
|
|
|
|
if [ -d $filename ]; then
|
|
|
|
|
for _ in $filename/*
|
|
|
|
|
do
|
2017-02-10 16:36:50 -05:00
|
|
|
markdownFile=${filename#$overviewFiles}.html
|
|
|
|
|
# Filename should be same as folder name with .html extension
|
|
|
|
|
if [ -e $filename/$markdownFile ]; then
|
|
|
|
|
cp -r $filename/$markdownFile $repoPath/overview/
|
2017-02-06 14:56:54 -05:00
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2017-04-10 09:52:19 -06:00
|
|
|
# Copy guide files over to $repoPath/guides
|
2017-02-10 16:36:50 -05:00
|
|
|
for filename in $overviewFiles*
|
|
|
|
|
do
|
|
|
|
|
if [ -f $filename ]; then
|
|
|
|
|
cp -r $filename $repoPath/guides
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2017-04-10 09:52:19 -06:00
|
|
|
# Copy highlighted examples into $repoPath
|
2017-02-10 16:36:50 -05:00
|
|
|
cp -r $examplesSource/* $repoPath/examples
|
2017-02-06 14:56:54 -05:00
|
|
|
|
2017-04-10 09:52:19 -06:00
|
|
|
# Copy example plunker assets
|
2017-04-12 17:40:31 -07:00
|
|
|
cp -r $docsPath/plunker/* $repoPath/plunker
|
2017-04-10 09:52:19 -06:00
|
|
|
|
2017-03-14 21:11:12 +01:00
|
|
|
# Copies assets over to the docs-content repository.
|
|
|
|
|
cp LICENSE $repoPath/
|
|
|
|
|
|
2017-02-06 14:56:54 -05:00
|
|
|
# Push content to repo
|
|
|
|
|
cd $repoPath
|
|
|
|
|
git config user.name "$commitAuthorName"
|
|
|
|
|
git config user.email "$commitAuthorEmail"
|
|
|
|
|
git config credential.helper "store --file=.git/credentials"
|
|
|
|
|
|
2017-03-31 11:51:22 -07:00
|
|
|
echo "https://${MATERIAL2_DOCS_CONTENT_TOKEN}:@github.com" > .git/credentials
|
2017-02-06 14:56:54 -05:00
|
|
|
|
|
|
|
|
git add -A
|
2017-07-18 23:45:17 +02:00
|
|
|
git commit --allow-empty -m "$commitMessage"
|
2017-02-06 14:56:54 -05:00
|
|
|
git tag "$commitSha"
|
|
|
|
|
git push origin master --tags
|