-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(scripts): push generated docs to material assets repo #2720
feat(scripts): push generated docs to material assets repo #2720
Conversation
.travis.yml
Outdated
@@ -33,6 +33,7 @@ env: | |||
- MODE=aot | |||
- MODE=payload | |||
- MODE=e2e | |||
- MODE=docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole mode shouldn't be necessary when we run it with the travis-after-modes
script.
# If the docs directory is not present, abort | ||
if [ ! -d $docsPath ]; then | ||
echo "Material docs not generated. Aborting..." | ||
exit 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not returning an exit code 1
here? If Travis turns red we can see that there are issues with the docs.
# git remote show origin | ||
git config user.name "$commitAuthorName" | ||
git config user.email "$commitAuthorEmail" | ||
git config credential.helper "store --file=.git/credentials" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the Github credentials are now retrieved from the .git/credentials
file, the credentials file needs to be created.
echo "https://${MATERIAL2_BUILDS_TOKEN}:@github.com" > .git/credentials
echo "returning to root and removing temp repo" | ||
cd $root | ||
rm -rf $tempRepoPath | ||
echo "Done!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that returning to the project directory is necessary here.
- Those scripts run most of the time in a child process and don't affect the users PWD.
git clone $repoUrl $tempRepoPath | ||
|
||
# Clean out repo directory and copy contents of dist/docs into it | ||
$(find $tempRepoPath -d 1 | grep -v "git" | xargs rm -rf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just calling rm -rf $tempRepoPath /*
?
The
.git
folder won't be affected because the wildcard doesn't cover.*
files / folders.
f101822
to
9d8847e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-wise LGTM.
Still thinking about a better name than
tmpRepoPath
.
cd "$(dirname $0)/../../" | ||
|
||
docsPath="./dist/docs" | ||
tempRepoPath="./dist/tempRepo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than writing to dist
/, /tmp/material2-docs-content
would be more appropriate (since it's not the output of a build).
I think that just repoDir
or repoPath
is good.
|
||
# Clean out repo directory and copy contents of dist/docs into it | ||
rm -rf $tempRepoPath/* | ||
mkdir $tempRepoPath/docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that the content needs to all go into a docs
directory. The structure should look something like
material2-docs-content
├─ overview
├─ guides
├─ api
└─ examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Realized I should add a bit more here; we should:
- Change the current
gulp docs
task to be calledgulp markdown-docs
- Change the current
gulp api
togulp api-docs
- Add a new task called
gulp docs
that just runs the previous two - Change
gulp api-docs
to output todist/docs/api
andmarkdown-docs
to output todist/docs/markdown
This should make it easier for this script to massage the different types of docs into the right place (and still only need to run one command).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also while we are talking about naming. Can we rename the file to publish-docs-content.sh
?
Artifacts sounds like we are building a release of the components
|
||
docsPath="./dist/docs" | ||
tempRepoPath="./dist/tempRepo" | ||
repoUrl="https://github.com/angular/material2-docs-content" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to let this do a few test runs before committing to the real repo. We did this for the material2-builds; you can do the same by:
- Fork angular/material2-docs-content
- Add an access token for said fork to our Travis CI environment
- Update this script to use that token instead of
MATERIAL2_BUILDS_TOKEN
We can then just let it run for a few commits and make sure it looks good before updating the repo / access token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think everybody can create Travis encrypted variables. I can create a small repo for it and we don't need to change the token at all. (Since its currently running over my token)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devversion That's probably easier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so here is the repository: https://github.com/DevVersion/material2-docs-content.git
@jelbourn In the future we can probably switch to another token.
9d8847e
to
23f4f38
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple last comments!
cd "$(dirname $0)/../../" | ||
|
||
docsPath="./dist/docs" | ||
repoPath="./tmp/material2-docs-content" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change to to /tmp
instead of ./tmp
?
(here and elsewhere)
overviewFiles=$docsPath/markdown/ | ||
|
||
# Move api files over to $repoPath/api | ||
cp -r $docsPath/api/ $repoPath/api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is creating a structure of material2-docs-assets/api/api
(api is in there twice)
51bbb77
to
ab8dd2d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@riavalon Can you rebase? |
ab8dd2d
to
ed277d0
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Setup scripts for pushing generated docs to material2-docs-content repo on release