Skip to content
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

Auto update gh-pages branch when docs are updated. #44

Closed
wants to merge 3 commits into from
Closed

Auto update gh-pages branch when docs are updated. #44

wants to merge 3 commits into from

Conversation

m-murad
Copy link
Contributor

@m-murad m-murad commented Oct 19, 2017

This PR is relate to #40
This will auto update gh-pages branch when master branch is updated.

@oliverroick please review.

@m-murad
Copy link
Contributor Author

m-murad commented Oct 19, 2017

Travis needs to be enabled for the project and an API key needs to be added in the travis console.

deploy.sh Outdated
exit 0
fi

git clone --quiet --branch=gh-pages https://oliverroick:[email protected]/cadasta/api-docs /home/travis/build/cadasta/docs-branch
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliverroick
You need to generate an API key and use it in travis.

  1. Read about generating an API key here.
  2. Once you generate the API key open the project in travis-ci.org.
  3. In settings tab add an environment variable. Name the variable API_KEY and value the key you generated.
    screen shot 2017-10-20 at 4 51 16 am

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create a bot user for these tasks, that build won't break when a user is removed from the team.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Copy link
Member

@oliverroick oliverroick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @m-murad, thanks for getting automated deploys started. That will make the process much easier for us.

I left a few comments that I would like you to address. Once we have accepted your changes, I'll enable the project on Travis so we can see if the project is built correctly.

deploy.sh Outdated
@@ -1,29 +1,26 @@
#!/bin/bash

rm -rf dddocs
rm -rf docs-build
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "cadasta/api-docs" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition looks wrong. The first part excludes all builds on pull requests, the second part excludes all builds that are not triggered from cadasta/api-docs, which will never become false, since all builds will always be triggered from cadasta/api-docs.

Connecting both with an OR operator (you're using -o) means the build will never exit.

As I suggested in my comment to the corresponding issue, I would use:

if ["$TRAVIS_TAG" != "false"]

That way we only ever deploy when a new version has been tagged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"$TRAVIS_REPO_SLUG" != "cadasta/api-docs"
This condition is for a scenario where commit or PR is made on the forked copy of this repository.
e.g. if I'm making the changes on my own copy of the repository i.e. m-murad/api-docs the auto update will be skipped.

deploy.sh Outdated
exit 0
fi

git clone --quiet --branch=gh-pages https://oliverroick:[email protected]/cadasta/api-docs /home/travis/build/cadasta/docs-branch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create a bot user for these tasks, that build won't break when a user is removed from the team.

deploy.sh Outdated
echo "Done."
git add .
git commit -m "Deploy docs"
git push origin gh-pages --quiet
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the time being, can we push this to another branch, maybe gh-pages-test? I want to see the script in action before we start overwriting docs website.

Once your changes are approved, I'll change that back.

deploy.sh Outdated
mkdir docs-build
npm install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too familiar with building Node projects on Travis. I'm assuming that Travis always runs npm install by default?!

Copy link
Contributor Author

@m-murad m-murad Oct 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does. You can check it here.

deploy.sh Outdated
rm -rf docs-build
echo "Done."
git add .
git commit -m "Deploy docs"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to use the content of $TRAVIS_TAG here to get nicer commit messages? For example, if we tag 1.0.1 that we end up with the commit message Deploy docs v1.0.1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not able to understand what you are trying to say.

I checked this repository but no tag has been created for this repository. Maybe if you can explain it to me.

What we can do we can use the commit message of the commit that is being build or the branch of the pull request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, no tags have been created so far. But we will create tags in the future to kick off the deployment process.

So whenever we think that what is on master is ready, we create a new tag, which deploys the docs. I don't want to deploy the docs with every push to master for a simple reason: When we build features for the API and document the changes, the changes to the documentation might be merged to master before the changes to the API are released. If we deploy with every push to master, the documentation won't match the current API and we can avoid that by tagging versions on master and deploy only when a new tag is created.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For that we can do something else.

Once a TAG is created at cadasta/cadasta-platform i will right a script that will create the TAG in this repository as well.

This way the docs will remain updated after every commit and when a new tag is created for cadasta-platform it will automatically create a tag for api-docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm suggesting updating the docs after every commit because after my PRs #37, #39, #36
The docs are still not updated to reflect the changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a TAG at cadasta/cadasta-platform and cadasta/api-docs at same time will makes sense. That way we can also corrosponde every version of cadasta-platform to its doc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm suggesting updating the docs after every commit because after my PRs #37, #39, #36
The docs are still not updated to reflect the changes.

We simply forgot; I'll take care of the deployment tomorrow. Updating the docs after every commit is still not an option.

Once a TAG is created at cadasta/cadasta-platform i will right a script that will create the TAG in this repository as well.

That's something we can do further down the line. I'd say we focus on this PR first and then look at follow-ups.

@m-murad
Copy link
Contributor Author

m-murad commented Oct 29, 2017

@oliverroick
Correct me if I'm wrong.
What you want is that - every time you create and push a tag, the gh-pages branch should be updated from the code thats in master branch?

@oliverroick
Copy link
Member

Yes that's correct

@m-murad
Copy link
Contributor Author

m-murad commented Oct 30, 2017

@oliverroick
I have updated the PR.
The gh-pages branch will only be updated if a TAG is pushed to the repository.

The commit message will be of the format
"Docs updated for TRAVIS_TAG"
eg Docs updated for v1.2

@m-murad
Copy link
Contributor Author

m-murad commented Nov 2, 2017 via email

@oliverroick
Copy link
Member

It's on my list. I'll review when I get to it. It's not the highest priority at the moment

@m-murad m-murad closed this Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants