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

Add support for deploying from TravisCI Tag Builds #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add support for deploying from TravisCI Tag Builds #4

wants to merge 1 commit into from

Conversation

jthegedus
Copy link

@jthegedus jthegedus commented Mar 8, 2017

Many people prefer to use git tags to trigger builds and deployments. gh-pages-travis doesn't currently support deploying from a TravisCI Tag Build as the environment variables in TravisCI are not set correctly. TravisCI sets the TRAVIS_TAG correctly, but Travis still currently sets TRAVIS_BRANCH to the Tag name, not the git branch name that the tagged commit occurred on. see: TravisCI issue 1675 This means that the comparison between the desired DEPLOY_BRANCH in gh-pages-travis and the TRAVIS_BRANCH always fails on Tag Builds.

The suggested change does the following:

  • exit early if a PR - as before
  • check if TRAVIS_BRANCH and TRAVIS_TAG are equal. If so, then it was a Tag Build, else it was a Branch Build.
  • If Branch Build, do as previous and compare TRAVIS_BRANCH to DEPLOY_BRANCH. If equal, deploy, else exit.
  • If Tag Build, get the name of the branch this tag was on. Compare that to DEPLOY_BRANCH. If equal, deploy, else exit (as the tag was not on the desired branch).

Additionally:

  • add more verbose logging in TravisCI log so to help debugging should people come across this issue as I did.

Other noteworthy tidbits:

  • when the git branch --contains tags/$TRAVIS_TAG command is executed, if the tag does not exist on the branch anywhere the output error from git is not particularly helpful. The error returned is error: malformed object name, however, this is not necessarily because the TRAVIS_TAG is erroneous, but rather that when the tag name is searched by git it transforms it to the SHA1 abbreviated ID and then attempts to expand that to the fully-qualified SHA1 which outputs this error (see). So if the searched Tag does not exist, this error is shown. This is unlikely to occur since the Tag should always exist on Travis initialisation, but if the tag is removed before the deploy, then it may show itself.

TravisCI uses the TRAVIS_TAG var as the TRAVIS_BRANCH var in a Tag Build, which breaks deployment since the TRAVIS_BRANCH var is not equal to the user specified DEPLOY_BRANCH. This allows deployment if the Tag is on the DEPLOY_BRANCH.
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.

1 participant