Publish to any gh-pages branch on GitHub (or any other branch on any other remote).
Made for angular-cli users.
Made with Travis-CI in mind.
Brought to you by the angular-buch.com / angular.schule team!
This command is similar to the old
github-pages:deploy command of @angular/cli which was removed in #4385.
The angular-cli-ghpages command is able to push to any branch on any repository. It's made on top of tschaub/gh-pages.
This script works great on Travis-CI. No git credentials must be set up in before. Specific environment variables of Travis-CI are evaluated, too. You will like it!
This command has the following prerequisites:
To install the command run the following:
npm i -g angular-cli-ghpages
angular-cli-ghpages in order to deploy the project with a build from
Note: you have to create the
dist folder in before (e.g.
ng build --prod)
ng build --prod --base-href ""angular-cli-ghpages [OPTIONS]
ng build --prod --base-href "/REPOSITORY_NAME/"angular-cli-ghpages [OPTIONS]
<base href=""> stays untouched)
ng build --prodangular-cli-ghpages [OPTIONS]
there is also a shorter
ngh command available
ng build --prod --base-href ""ngh [OPTIONS]
If you want to push to
gh-pages on the same repository with your default credentials, then just enter
ngh without any options.
Output usage information.
Output the version number. Please provide the version number on any bug report!
By default, gh-pages assumes that the current working directory is a git repository,
and that you want to push changes to the
If instead your files are not in a git repository, or if you want to push to another repository,
you can provide the repository URL in the
ngh --message="What could possibly go wrong?"
The commit message, must be wrapped in quotes.
Some handy additional text is always added, if the environment variable
process.env.TRAVIS exists (for Travis CI).
The name of the branch you'll be pushing to.
The default uses GitHub's
but this can be configured to push to any branch on any remote.
git config user.nameand
git config user.email
ngh --name="Displayed Username" --email@example.com
If you are running the command in a repository without a
user.email git config properties
(or on a machine without these global config properties),
you must provide user info before git allows you to commit.
In this case provide both
ngh-- Logging is in silent mode by default.
ngh --no-silent-- Logging shows extended information.
Logging is in silent mode by default. In silent mode log messages are suppressed and error messages are sanitized.
--no-silent option enables extended console logging.
Keep this untouched if the repository URL or other information passed to git commands is sensitive!
WARNING: This option should kept like it is if the repository URL or other information passed to git commands is sensitive and should not be logged (== you have a public build server). By default the silent mode is enabled to avoid sensitive data exposure.
Directory for all published sources, relative to the project-root.
Most probably no change is required here. This option can be used to deploy completely different folders, which are not related at all to angular.
ngh-- Dotfiles are included by default.
ngh --no-dotfiles-- Dotfiles are ignored.
The command includes dotfiles by default (e.g
.htaccess will be committed)
--no-dotfiles files starting with
. are ignored.
ngh-- Normal behaviour: Changes are applied.
ngh --dry-run-- No changes are applied at all.
Run through without making any changes. This can be very usefull, because it outputs what would happend without doing anything.
For your convenience, the command will recognize the environment variable
GH_TOKEN and will replace this pattern in the
--repo string. Please do NOT disable the silent mode if you have any credentials in the repository URL! Read more about Github tokens here.
In example, the following command runs on our Travis-CI:
angular-cli-ghpages --repo= --name="Displayed Username" --firstname.lastname@example.org
You have to treat the GH_TOKEN as secure as a password!
Before posting any issue, please read the FAQ first.
Code released under the MIT license.