Skip to content

Commit

Permalink
feat(scripts): push generated docs to material assets repo
Browse files Browse the repository at this point in the history
  • Loading branch information
riavalon committed Jan 19, 2017
1 parent d4ab3d3 commit 9d8847e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/ci/after-success.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ cd $(dirname $0)/../..
if [ "$TRAVIS_PULL_REQUEST" = "false" ] && $(npm bin)/travis-after-modes; then
echo "All travis modes passed. Publishing the build artifacts..."
./scripts/release/publish-build-artifacts.sh
fi
./scripts/release/publish-docs-artifacts.sh
fi
44 changes: 44 additions & 0 deletions scripts/release/publish-docs-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/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

cd "$(dirname $0)/../../"

docsPath="./dist/docs"
tempRepoPath="./dist/tempRepo"
repoUrl="https://github.com/angular/material2-docs-content"

# If the docs directory is not present, generate docs
if [ ! -d $docsPath ]; then
$(npm bin)/gulp docs
fi

# 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
rm -rf $tempRepoPath
mkdir $tempRepoPath
git clone $repoUrl $tempRepoPath

# Clean out repo directory and copy contents of dist/docs into it
rm -rf $tempRepoPath/*
mkdir $tempRepoPath/docs
cp -r $docsPath/* $tempRepoPath/docs

# Push content to repo
cd $tempRepoPath
git config user.name "$commitAuthorName"
git config user.email "$commitAuthorEmail"
git config credential.helper "store --file=.git/credentials"

echo "https://${MATERIAL2_BUILDS_TOKEN}:@github.com" > .git/credentials

git add -A
git commit -m "$commitMessage"
git tag "$commitSha"
git push origin master --tags

0 comments on commit 9d8847e

Please sign in to comment.