@@ -14,82 +14,77 @@ if [ -z ${MATERIAL2_DOCS_CONTENT_TOKEN} ]; then
1414 exit 1
1515fi
1616
17- docsPath=" ./dist/docs"
18- packagePath=" ./dist/releases/material-examples"
19- repoPath=" /tmp/material2-docs-content"
20- repoUrl=" https://github.com/angular/material2-docs-content"
21- examplesSource=" ./dist/docs/examples"
22-
2317if [[ ! ${* } == * --no-build* ]]; then
2418 $( npm bin) /gulp material-examples:build-release:clean
2519 $( npm bin) /gulp docs
2620fi
2721
28- # Get git meta info for commit
29- commitSha=" $( git rev-parse --short HEAD) "
30- commitAuthorName=" $( git --no-pager show -s --format=' %an' HEAD) "
31- commitAuthorEmail=" $( git --no-pager show -s --format=' %ae' HEAD) "
32- commitMessage=" $( git log --oneline -n 1) "
33-
34- # create directory and clone test repo
35- rm -rf $repoPath
36- mkdir -p $repoPath
37- git clone $repoUrl $repoPath --depth 1
38-
39- # Clean out repo directory and copy contents of dist/docs into it
40- rm -rf $repoPath /*
41-
42- # Create folders that will contain docs content files.
43- mkdir $repoPath /{overview,guides,api,examples,stackblitz,examples-package}
44-
45- # Copy api files over to $repoPath/api
46- cp -r $docsPath /api/* $repoPath /api
47-
48- # Copy the material-examples package to the docs content repository.
49- cp -r $packagePath /* $repoPath /examples-package
50-
51- # Flatten the markdown docs structure and move it into $repoPath/overview
52- overviewFiles=$docsPath /markdown/
53- for filename in $overviewFiles *
54- do
55- if [ -d $filename ]; then
56- for _ in $filename /*
57- do
58- markdownFile=${filename# $overviewFiles } .html
59- # Filename should be same as folder name with .html extension
60- if [ -e $filename /$markdownFile ]; then
61- cp -r $filename /$markdownFile $repoPath /overview/
62- fi
63- done
64- fi
65- done
22+ # Path to the directory that contains the generated docs output.
23+ docsDistPath=" ./dist/docs"
6624
67- # Copy guide files over to $repoPath/guides
68- for filename in $overviewFiles *
69- do
70- if [ -f $filename ]; then
71- cp -r $filename $repoPath /guides
72- fi
73- done
25+ # Path to the release output of the @angular/material-examples package.
26+ examplesPackagePath=" ./dist/releases/material-examples"
27+
28+ # Path to the cloned docs-content repository.
29+ docsContentPath=./tmp/material2-docs-content
30+
31+ # Git clone URL for the material2-docs-content repository.
32+ docsContentRepoUrl=" https://github.com/angular/material2-docs-content"
33+
34+ # Current version of Angular Material from the package.json file
35+ buildVersion=$( node -pe " require('./package.json').version" )
36+
37+ # Additional information about the last commit for docs-content commits.
38+ commitSha=$( git rev-parse --short HEAD)
39+ commitAuthorName=$( git --no-pager show -s --format=' %an' HEAD)
40+ commitAuthorEmail=$( git --no-pager show -s --format=' %ae' HEAD)
41+ commitMessage=$( git log --oneline -n 1)
42+ commitTag=" ${buildVersion} -${commitSha} "
43+
44+ # Remove the docs-content repository if the directory exists
45+ rm -Rf ${docsContentPath}
7446
75- # Copy highlighted examples into $repoPath
76- cp -r $examplesSource / * $repoPath /examples
47+ # Clone the docs-content repository.
48+ git clone ${docsContentRepoUrl} ${docsContentPath} --depth 1
7749
78- # Copy example stackblitz assets
79- cp -r $docsPath /stackblitz/* $repoPath /stackblitz
50+ # Remove everything inside of the docs-content repository.
51+ rm -Rf ${docsContentPath} /*
52+
53+ # Create all folders that need to exist in the docs-content repository.
54+ mkdir ${docsContentPath} /{overview,guides,api,examples,stackblitz,examples-package}
55+
56+ # Copy API and example files to the docs-content repository.
57+ cp -R ${docsDistPath} /api/* ${docsContentPath} /api
58+ cp -r ${docsDistPath} /examples/* ${docsContentPath} /examples
59+ cp -r ${docsDistPath} /stackblitz/* ${docsContentPath} /stackblitz
60+
61+ # Copy the @angular/material-examples package to the docs-content repository.
62+ cp -r ${examplesPackagePath} /* ${docsContentPath} /examples-package
63+
64+ # Copy the license file to the docs-content repository.
65+ cp ./LICENSE ${docsContentPath}
66+
67+ # Copy all immediate children of the markdown output the guides/ directory.
68+ for guidePath in $( find ${docsDistPath} /markdown/ -maxdepth 1 -type f) ; do
69+ cp ${guidePath} ${docsContentPath} /guides
70+ done
71+
72+ # All files that aren't immediate children of the markdown output are overview documents.
73+ for overviewPath in $( find ${docsDistPath} /markdown/ -mindepth 2 -type f) ; do
74+ cp ${overviewPath} ${docsContentPath} /overview
75+ done
8076
81- # Copies assets over to the docs-content repository.
82- cp LICENSE $repoPath /
77+ # Go into the repository directory .
78+ cd ${docsContentPath}
8379
84- # Push content to repo
85- cd $repoPath
80+ # Setup the Git configuration
8681git config user.name " $commitAuthorName "
8782git config user.email " $commitAuthorEmail "
8883git config credential.helper " store --file=.git/credentials"
8984
9085echo " https://${MATERIAL2_DOCS_CONTENT_TOKEN} :@github.com" > .git/credentials
9186
9287git add -A
93- git commit --allow-empty -m " $commitMessage "
94- git tag " $commitSha "
88+ git commit --allow-empty -m " ${ commitMessage} "
89+ git tag " ${commitTag} "
9590git push origin master --tags
0 commit comments