|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Publish material2 docs assets to the material2-docs-content repo |
| 4 | +# material.angular.io will pull from this assets repo to get the latest docs |
| 5 | + |
| 6 | +cd "$(dirname $0)/../../" |
| 7 | + |
| 8 | +docsPath="/dist/docs" |
| 9 | +repoPath="/tmp/material2-docs-content" |
| 10 | +repoUrl="https://github.com/DevVersion/material2-docs-content" |
| 11 | + |
| 12 | +# If the docs directory is not present, generate docs |
| 13 | +if [ ! -d $docsPath ]; then |
| 14 | + $(npm bin)/gulp docs |
| 15 | +fi |
| 16 | + |
| 17 | +# Get git meta info for commit |
| 18 | +commitSha="$(git rev-parse --short HEAD)" |
| 19 | +commitAuthorName="$(git --no-pager show -s --format='%an' HEAD)" |
| 20 | +commitAuthorEmail="$(git --no-pager show -s --format='%ae' HEAD)" |
| 21 | +commitMessage="$(git log --oneline -n 1)" |
| 22 | + |
| 23 | +# create directory and clone test repo |
| 24 | +rm -rf "/tmp/" |
| 25 | +mkdir "/tmp/" $repoPath |
| 26 | +git clone $repoUrl $repoPath |
| 27 | + |
| 28 | +# Clean out repo directory and copy contents of dist/docs into it |
| 29 | +rm -rf $repoPath/* |
| 30 | +mkdir $repoPath/overview |
| 31 | +mkdir $repoPath/guides |
| 32 | +mkdir $repoPath/api |
| 33 | +# mkdir $repoPath/examples |
| 34 | + |
| 35 | +# Move api files over to $repoPath/api |
| 36 | +cp -r $docsPath/api/* $repoPath/api |
| 37 | + |
| 38 | +# Move guide files over to $repoPath/guides |
| 39 | +for filename in $overviewFiles* |
| 40 | +do |
| 41 | + if [ -f $filename ]; then |
| 42 | + cp -r $filename $repoPath/guides |
| 43 | + fi |
| 44 | +done |
| 45 | + |
| 46 | +# Flatten the markdown docs structure and move it into $repoPath/overview |
| 47 | +overviewFiles=$docsPath/markdown/ |
| 48 | +targetFile="OVERVIEW.html" |
| 49 | +for filename in $overviewFiles* |
| 50 | +do |
| 51 | + if [ -d $filename ]; then |
| 52 | + for _ in $filename/* |
| 53 | + do |
| 54 | + if [ -f $filename/$targetFile ]; then |
| 55 | + name=${filename#$overviewFiles} |
| 56 | + cp -r $filename/$targetFile $repoPath/overview/ |
| 57 | + mv $repoPath/overview/$targetFile $repoPath/overview/$name.html |
| 58 | + fi |
| 59 | + done |
| 60 | + fi |
| 61 | +done |
| 62 | + |
| 63 | +# src/examples should be added to the $repoPath after they have been moved into |
| 64 | +# the material2 repo from material.angular.io |
| 65 | + |
| 66 | +# Push content to repo |
| 67 | +cd $repoPath |
| 68 | +git config user.name "$commitAuthorName" |
| 69 | +git config user.email "$commitAuthorEmail" |
| 70 | +git config credential.helper "store --file=.git/credentials" |
| 71 | + |
| 72 | +echo "https://${MATERIAL2_BUILDS_TOKEN}:@github.com" > .git/credentials |
| 73 | + |
| 74 | +git add -A |
| 75 | +git commit -m "$commitMessage" |
| 76 | +git tag "$commitSha" |
| 77 | +git push origin master --tags |
0 commit comments