GithubHelp home page GithubHelp logo

tschaub / gh-pages Goto Github PK

View Code? Open in Web Editor NEW
3.2K 23.0 190.0 877 KB

General purpose task for publishing files to a gh-pages branch on GitHub

Home Page: https://www.npmjs.com/package/gh-pages

License: MIT License

JavaScript 97.12% Shell 2.76% CoffeeScript 0.07% CSS 0.04%

gh-pages's Introduction

gh-pages

Publish files to a gh-pages branch on GitHub (or any other branch anywhere else).

Getting Started

npm install gh-pages --save-dev

This module requires Git >= 1.9 and Node > 14.

Basic Usage

var ghpages = require('gh-pages');

ghpages.publish('dist', function(err) {});

publish

ghpages.publish(dir, callback);
// or...
ghpages.publish(dir, options, callback);

Calling this function will create a temporary clone of the current repository, create a gh-pages branch if one doesn't already exist, copy over all files from the base path, or only those that match patterns from the optional src configuration, commit all changes, and push to the origin remote.

If a gh-pages branch already exists, it will be updated with all commits from the remote before adding any commits from the provided src files.

Note that any files in the gh-pages branch that are not in the src files will be removed. See the add option if you don't want any of the existing files removed.

  • type: string

The base directory for all source files (those listed in the src config property).

Example use:

/**
 * Given the following directory structure:
 *
 *   dist/
 *     index.html
 *     js/
 *       site.js
 *
 * The usage below will create a `gh-pages` branch that looks like this:
 *
 *   index.html
 *   js/
 *     site.js
 *
 */
ghpages.publish('dist', callback);

Options

The default options work for simple cases. The options described below let you push to alternate branches, customize your commit messages and more.

  • type: string|Array<string>
  • default: '**/*'

The minimatch pattern or array of patterns is used to select which files should be published.

  • type: string
  • default: 'gh-pages'
  • -b | --branch <branch name>

The name of the branch you'll be pushing to. The default uses GitHub's gh-pages branch, but this can be configured to push to any branch on any remote.

Example use of the branch option:

/**
 * This task pushes to the `master` branch of the configured `repo`.
 */
ghpages.publish('dist', {
  branch: 'master',
  repo: 'https://example.com/other/repo.git'
}, callback);
  • type: string
  • default: '.'

The destination folder within the destination branch. By default, all files are published to the root of the repository.

Example use of the dest option:

/**
 * Place content in the static/project subdirectory of the target
 * branch.
 */
ghpages.publish('dist', {
  dest: 'static/project'
}, callback);
  • type: boolean
  • default: false

Include dotfiles. By default, files starting with . are ignored unless they are explicitly provided in the src array. If you want to also include dotfiles that otherwise match your src patterns, set dotfiles: true in your options.

Example use of the dotfiles option:

/**
 * The usage below will push dotfiles (directories and files)
 * that otherwise match the `src` pattern.
 */
ghpages.publish('dist', {dotfiles: true}, callback);
  • type: boolean
  • default: false

Write out a .nojekyll file to bypass Jekyll on GitHub Pages.

Example use of the nojekyll option:

/**
 * The usage below will add a `.nojekyll` file to the output.
 */
ghpages.publish('dist', {nojekyll: true}, callback);
  • type: string

Write out a CNAME file with a custom domain name.

Example use of the cname option:

/**
 * The usage below will add a `CNAME` file to the output.
 */
ghpages.publish('dist', {cname: 'custom-domain.com'}, callback);
  • type: boolean
  • default: false

Only add, and never remove existing files. By default, existing files in the target branch are removed before adding the ones from your src config. If you want the task to add new src files but leave existing ones untouched, set add: true in your options.

Example use of the add option:

/**
 * The usage below will only add files to the `gh-pages` branch, never removing
 * any existing files (even if they don't exist in the `src` config).
 */
ghpages.publish('dist', {add: true}, callback);
  • type: string
  • default: url for the origin remote of the current dir (assumes a git repository)
  • -r | --repo <repo url>

By default, gh-pages assumes that the current working directory is a git repository, and that you want to push changes to the origin remote.

If instead your script is not in a git repository, or if you want to push to another repository, you can provide the repository URL in the repo option.

Example use of the repo option:

/**
 * If the current directory is not a clone of the repository you want to work
 * with, set the URL for the repository in the `repo` option.  This usage will
 * push all files in the `src` config to the `gh-pages` branch of the `repo`.
 */
ghpages.publish('dist', {
  repo: 'https://example.com/other/repo.git'
}, callback);
  • type: string
  • default: 'origin'

The name of the remote you'll be pushing to. The default is your 'origin' remote, but this can be configured to push to any remote.

Example use of the remote option:

/**
 * This task pushes to the `gh-pages` branch of of your `upstream` remote.
 */
ghpages.publish('dist', {
  remote: 'upstream'
}, callback);
  • type: string
  • default: ''

Create a tag after committing changes on the target branch. By default, no tag is created. To create a tag, provide the tag name as the option value.

  • type: string
  • default: 'Updates'

The commit message for all commits.

Example use of the message option:

/**
 * This adds commits with a custom message.
 */
ghpages.publish('dist', {
  message: 'Auto-generated commit'
}, callback);
  • type: Object
  • default: null

If you are running the gh-pages task in a repository without a user.name or 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. The options.user object accepts name and email string values to identify the committer.

Example use of the user option:

ghpages.publish('dist', {
  user: {
    name: 'Joe Code',
    email: '[email protected]'
  }
}, callback);
  • type: string
  • default: '.'

Removes files that match the given pattern (Ignored if used together with --add). By default, gh-pages removes everything inside the target branch auto-generated directory before copying the new files from dir.

Example use of the remove option:

ghpages.publish('dist', {
  remove: "*.json"
}, callback);
  • type: boolean
  • default: true

Push branch to remote. To commit only (with no push) set to false.

Example use of the push option:

ghpages.publish('dist', {push: false}, callback);
  • type: boolean
  • default: true

Push force new commit without parent history.

Example use of the history option:

ghpages.publish('dist', {history: false}, callback);
  • type: boolean
  • default: false

Avoid showing repository URLs or other information in errors.

Example use of the silent option:

/**
 * This configuration will avoid logging the GH_TOKEN if there is an error.
 */
ghpages.publish('dist', {
  repo: 'https://' + process.env.GH_TOKEN + '@github.com/user/private-repo.git',
  silent: true
}, callback);
  • type: function
  • default: null

Custom callback that is executed right before git add.

The CLI expects a file exporting the beforeAdd function

gh-pages --before-add ./cleanup.js

Example use of the beforeAdd option:

/**
 * beforeAdd makes most sense when `add` option is active
 * Assuming we want to keep everything on the gh-pages branch
 * but remove just `some-outdated-file.txt`
 */
ghpages.publish('dist', {
  add: true,
  async beforeAdd(git) {
    return git.rm('./some-outdated-file.txt');
  }
}, callback);
  • type: string
  • default: 'git'

Your git executable.

Example use of the git option:

/**
 * If `git` is not on your path, provide the path as shown below.
 */
ghpages.publish('dist', {
  git: '/path/to/git'
}, callback);

Command Line Utility

Installing the package creates a gh-pages command line utility. Run gh-pages --help to see a list of supported options.

With a local install of gh-pages, you can set up a package script with something like the following:

"scripts": {
  "deploy": "gh-pages -d dist"
}

And then to publish everything from your dist folder to your gh-pages branch, you'd run this:

npm run deploy

GitHub Pages Project Sites

There are three types of GitHub Pages sites: project, user, and organization. Since project sites are not hosted on the root <user|org>.github.io domain and instead under a URL path based on the repository name, they often require configuration tweaks for various build tools and frameworks. If not configured properly, a browser will usually log net::ERR_ABORTED 404 errors when looking for compiled assets.

Examples:

When using a project site, be sure to read the documentation for your particular build tool or framework to learn how to configure correct asset paths.

Debugging

To get additional output from the gh-pages script, set NODE_DEBUG=gh-pages. For example:

NODE_DEBUG=gh-pages npm run deploy

Dependencies

Note that this plugin requires Git 1.9 or higher (because it uses the --exit-code option for git ls-remote). If you'd like to see this working with earlier versions of Git, please open an issue.

Test Status

Tips

when get error branch already exists

{ ProcessError: fatal: A branch named 'gh-pages' already exists.

    at ChildProcess.<anonymous> (~/node_modules/gh-pages/lib/git.js:42:16)
    at ChildProcess.emit (events.js:180:13)
    at maybeClose (internal/child_process.js:936:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
  code: 128,
  message: 'fatal: A branch named \'gh-pages\' already exists.\n',
  name: 'ProcessError' }

The gh-pages module writes temporary files to a node_modules/.cache/gh-pages directory. The location of this directory can be customized by setting the CACHE_DIR environment variable.

If gh-pages fails, you may find that you need to manually clean up the cache directory. To remove the cache directory, run node_modules/gh-pages/bin/gh-pages-clean or remove node_modules/.cache/gh-pages.

Deploying to github pages with custom domain

Use the --cname option to create a CNAME file with the name of your custom domain. See the GitHub docs for more detail.

gh-pages -d build --cname custom-domain.com"

Deploying with GitHub Actions

In order to deploy with GitHub Actions, you will need to define a user and set the git repository for the process. See the example step below

- name: Deploy with gh-pages
  run: |
    git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
    npx gh-pages -d build -u "github-actions-bot <[email protected]>"
   env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The secrets.GITHUB_TOKEN is provided automatically as part of the GitHub Action and does not require any further configuration, but simply needs to be passed in as an environmental variable to the step. GITHUB_REPOSITORY is the owner and repository name and is also passed in automatically, but does not need to be added to the env list.

See Issue #345 for more information

Deploying with GitHub Actions and a named script

If you are using a named script in the package.json file to deploy, you will need to ensure you pass the variables properly to the wrapped gh-pages script. Given the package.json script below:

"scripts": {
  "deploy": "gh-pages -d build"
}

You will need to utilize the -- option to pass any additional arguments:

- name: Deploy with gh-pages
  run: |
    git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
    npm run deploy -- -u "github-actions-bot <[email protected]>"
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

See Pull Request #368 for more information.

gh-pages's People

Contributors

afc163 avatar ambyjkl avatar amtrack avatar avivahl avatar cizordj avatar cvan avatar demee avatar dependabot[bot] avatar domsleee avatar dplusic avatar greenkeeper[bot] avatar greenkeeperio-bot avatar jrjurman avatar lelandmiller avatar mandeldl avatar markdalgleish avatar mickelsonmichael avatar moox avatar n1k0 avatar nezteb avatar okuryu avatar polyglotm avatar sobolevn avatar sunghwan2789 avatar timaschew avatar tschaub avatar tusharmath avatar vicropht avatar victoire44 avatar willbanders avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gh-pages's Issues

UnhandledPromiseRejectionWarning

I'm trying to debug why this happens, but the stack trace doesnt appear to be very useful

Cloning /root/doug-app-origin into ../doug/packages/doug/node_modules/gh-pages/.cache
Cleaning
Fetching origin
Checking out origin/gh-pages
Removing files
Copying files
Adding all
Committing
Pushing
Error
    at ChildProcess.<anonymous> (/root/doug/packages/doug/node_modules/gh-pages/lib/git.js:47:23)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:885:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
(node:310) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: true
(node:310) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

ProcessError: fatal: A branch named 'test-pages' already exists.

Hey there,

I wanted to test this tool on a local branch before having things thrown at the remote gh-pages. For that reason I created a local branch off of gh-pages and called it test-pages - it has no upstream. When running gh-pages with the following options, I get an error thrown at me

{
  branch: 'test-pages',
  push: false,
  message: 'chore(website): pushing website to test-pages',
}

and the error I see is

{ [ProcessError: fatal: A branch named 'test-pages' already exists.
]
  code: 128,
  message: 'fatal: A branch named \'test-pages\' already exists.\n',
  name: 'ProcessError' }

I have then pushed test-pages to the remote and tried again. This time I did not see an error, however the local test-pages did not contain any updates. I then removed the push: false option and tried again. There was no error, the local test-pages did not show any changes, but the remote test-pages had the proper content!

It is possible I've misunderstood how to use the options branch and push, but at the moment I fear the docs don't match reality.

Allow .cache directory to be configurable?

It looks like gh-pages figures out .cache dir like this:

function getCacheDir() {
  return path.relative(process.cwd(), path.resolve(__dirname, '../.cache'));
}

This can get rather nasty in case you are using gh-pages in a cli wrapper. What if we introduced cachePath option that, if set, would override this function? This would give me the flexibility I need.

Preserve permissions

Hello,

Permissions are not preserved when gh-pages copies files to the cache dir.

Do you think it is a relevant to add code to transfer permissions in the copyFile function?

Regards,

Allow an array of files to be passed through `src`

I had some troubles getting glob work the way I wanted today. It gets a little complicated in certain cases (multiple files/directories to match). It might be neat if src could accept an array of filenames. This way you could use whatever library you want on the user side. glob is a good default. I feel this would be a nice extension point, though, as it's just a single check on your side.

Don't remove CNAME

I use Webpack to build my project and output to ./dist directory. I have a CNAME file in my gh-pages, but it don't in the ./dist directory after Webapack build, so when I run gh-pages -d dist, it remove my CNAME.

I can run gh-pages -d dist -a but I use Long-term Caching, so if I added -a, the file will be more and more in the gh-pages.

Can you add an option that don't remove the CNAME file?

Use an alternative to q-io/fs

I've been using this module with great enjoyment, but sadly it breaks other code by simply requiring it. You can find the details here: ipfs/aegir#79 (comment). The gist is, that q-io uses a module collections which modifies global prototypes.

This could be easily fixed here, by using something another promise wrapper around fs than q-io. I've also opened an issue on q-io to fix this, but wanted to mention this here as well. kriskowal/q-io#160

Pass array to --src option in command line

Hello @tschaub,

First of all, great piece of work. It helps me a lot. Thank you.

I have one question (or feature request).
I can't pass array of patterns to --src option in CLI. How can I do it?

If there is no way to do it. How about adding it? I can send PR (with your help :D )

Thank you.

Add a silent option to hide repo

When using a github token to deploy from travis, currently the url is exposed (so the token).
An option to hide this is required. I will try to push a PR asap.

Is this project still maintained?

I am considering using this package in a project of mine, but I am concerned about the high number of issues and pull requests that don't seem to be getting that much attention from the maintainers. I understand that it is open-source and that people get busy with other things and that is fine. I am just honestly curious as to whether this project still maintained. Thanks!

throw new TypeError (Path must be a string)

this is my publish commond in npm scripts:

"scripts": {
    "deploy": "gh-pages -b demo -s {docs/**/*,build/**/*,index.html}",
},

when I run it, it's going to be wrong.throw an exception

path.js:8
    throw new TypeError('Path must be a string. Received ' +
    ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:8:11)
    at Object.posix.join (path.js:479:5)
    at Object.<anonymous> (/Users/chenchaoqun/GitLab/aliqin/vue-component/node_modules/gh-pages/bin/gh-pages:23:22)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:457:10)
    at startup (node.js:136:18)
    at node.js:972:3

when I use the nodejs code to run, it will not be reported to the wrong, how to solve this problem?

gh-page npm WARN deprecated [email protected]: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.

npm WARN deprecated [email protected]: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.

─┬ [email protected]
└── [email protected]

SSH vs HTTPS

I was having an issue on a couple of repos in which we have set up to deploy using gh-pages from Travis. This was setup using Githubs deploys keys and Travis's encrypted file support, similar to this setup.

However it seems gh-pages clones using the https urls, so the remote will then be set to https and not shh, which is what is required to pick up the added ssh key on Travis. This would cause the push task to fail.

This can be overcome by specifying --repo [email protected]:{FOO}/{BAR}.git ... but would you be open to adding an ssh option to take care of this?

gh-pages seems to be using --global user.email

First off, fantastic module, thanks for it :)

I'm running this command in a repository where my git config user.email differs from my global setting, however it seems to be trying to execute commands using my git config --global user.email instead, which is causing my pushes to be rejected. Setting my user.email to the appropriate email globally fixes the problem.

This may be an id10t error on my part due to some configurations I have locally, but I can't see that I have anything set up wrong, so wanted to see if you could reproduce locally.

gh-pages -d dist overwrites custom domain

When I use my npm script like so

    "deploy": "npm run build:prod &&  gh-pages -d dist"

My custom domain is overwritten by gh-pages to be my default Github Pages project domain. I have to go into my Github project settings and make the domain my custom domain every time.

How to handle parallel releases?

Hi,

I ran into an interesting problem at webpack.js.org. Basically we handle deployment through gh-pages and Travis. Travis picks up changes made to master, builds, and then deploys (gh-pages).

The problem is that if I merge multiple PRs, it's possible Travis will trigger parallel builds. This can lead to Git state that's not consistent at the gh-pages branch.

Do you have any idea how to handle this kind of syncing issue? Maybe solving that at Travis would be the way (assuming it gives access to process info). Ideas are welcome.

branch: "master" option appears to fail

I have set up a little cli wrapper for gh-pages. While testing it I noticed it doesn't allow master branch to be replaced. It emits

{ [ProcessError: fatal: A branch named 'master' already exists.
]
  code: 128,
  message: 'fatal: A branch named \'master\' already exists.\n',
  name: 'ProcessError' }

I managed to write a little script like this to work around the issue:

# go to the out directory and create a *new* Git repo
cd build

# Remove possible existing git repo. We'll replace entire gh-pages.
rm -rf .git

# Init new repo
git init

# The first and only commit to this new Git repo contains all the
# files present with the commit message "Deploy to GitHub Pages".
git add .
git commit -m "Deploy to GitHub Pages"

# Add origin
git remote add origin <my repo>

# Force push from the current repo's master branch to the remote
# repo's master branch. (All previous history on the master branch
# will be lost, since we are overwriting it.)
git push --force origin master:master

Maybe this could give you some idea on how to fix the issue.

Cache per repo?

With the globally installed gh-pages executable, trying to deploy multiple repos causes conflicts in the .cache directory. It'd be handy of repos were cloned to their own directory within the .cache directory to avoid conflicts.

Port tests

The grunt-gh-pages integration tests are gnarly. At a minimum, the unit tests should be ported. It will likely be more straightforward to rewrite the integration tests without a task runner (neither grunt nor gulp).

Removing remote gh-pages branch causes crash (with workaround)

I love this module, thanks : )

I decided to blow away my gh-pages branch from github, and start fresh. When I did this, and re-ran my script, I got the following error:

Cloning [email protected]:.../....git into node_modules/gh-pages/.cache
Cleaning
Fetching origin
{ [ProcessError: fatal: Couldn't find remote ref refs/heads/gh-pages]
  code: 128,
  message: 'fatal: Couldn\'t find remote ref refs/heads/gh-pages\n',
  name: 'ProcessError' }

I fixed this by simply reinstalling the package:

rm -rf node_modules/gh-pages/ && npm install

And all worked fine. Just wanted to report the issue in case it is helpful, or in case it helps others who may be searching for a fix.

Unable to run clean task

When I have made some changes in the configuration, the tool said me the following

Remote url mismatch.  Got "<something>" but expected "<something-else>" in node_modules/gh-pages/.cache. 
If you have changed your "repo" option, try running the "clean" task first.

I have tried to run gh-pages clean, but it didn't succeed. What kind of task should I run to clean the cache?

"Remote url mismatch" error refers to the "clean" Grunt task

If you encounter the "Remote url mismatch" error, the instructions for correcting the issue are still Grunt-specific:

"Remote url mismatch. Got "X" but expected "Y" in node_modules/gh-pages/.cache. If you have changed your "repo" option, try running the "clean" task first."

Add orphan/force push option

When you have a website with a lot of pages, versionning gh-pages can start to be a problem. I have a repo that is almost 100MB for the single gh-pages. I would like to add an option to checkout --orphan gh-pages and so be able to force push. Are you open to a PR for this option (name: orphanBranch) ?

Trying to use this in a global package but having issues with permissions

I have the following script, which I have installed globally:

#!/usr/bin/env node

const path = require('path');
const yargs = require('yargs').argv;
const ghpages = require('gh-pages');

ghpages.publish(path.join(process.cwd(), './dist'), {
  branch: 'master'
}, err => {
  console.log(err, process.cwd());
});

I am getting the following error:

{ ProcessError: fatal: could not create work tree dir '../../../../usr/lib/node_modules/gh-deploy-extended/node_modules/gh-pages/.cache': Permission denied

    at ChildProcess.<anonymous> (/usr/lib/node_modules/gh-deploy-extended/node_modules/gh-pages/lib/git.js:47:23)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:852:16)
    at Socket.<anonymous> (internal/child_process.js:323:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:492:12)
  code: 128,
  message: 'fatal: could not create work tree dir \'../../../../usr/lib/node_modules/gh-deploy-extended/node_modules/gh-pages/.cache\': Permission denied\n',
  name: 'ProcessError' } '/home/otis/Developer/portfolio'

If I add the following option: clone: '/tmp/gh-pages' I stop getting permission errors and get the following:

{ Error: ENOENT: no such file or directory, mkdir ''
    at Error (native) errno: -2, code: 'ENOENT', syscall: 'mkdir', path: '' } '/home/otis/Developer/portfolio'

Any ideas?
Cheers.

Error with signed commit

I always use git with commit.gpgsign=true.
When I use gh-pages to publish, I get error.

gpg: cannot open tty `no tty': No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object

Is it posible to commit with gpg signed?

Anyway to deploy to master?

#14 is related but I am not sure?

Wanting to deploy to master for a user repo which does not read from gh-pages.

Cheers.

Multiple push urls for a remote

gh-pages does not use the fetch url for the remote if there are multiple urls tied to a single remote. Instead it uses the last one in the list. I'd expect it to use the fetch as I would consider that the main source.

I use both BitBucket and Github and try to keep them in sync. As such I push to both by adding an additional URL to the origin remote. This is what my .git/config looks like for the remotes section:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = https://bitbucket.org/RayBenefield/ghpages-react-redux-router-md.git
	url = https://github.com/RayBenefield/ghpages-react-redux-router-md.git

The above works fine, as the git command used to get the remote url (git config --get remote.origin.url) results in https://github.com/RayBenefield/ghpages-react-redux-router-md.git. However fetching is tied to the very first url in the remote list. So in the above instance, the fetch url is actually https://bitbucket.org/RayBenefield/ghpages-react-redux-router-md.git.

Originally I had it switched around and wondered why it wasn't working. If the config looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = https://github.com/RayBenefield/ghpages-react-redux-router-md.git
	url = https://bitbucket.org/RayBenefield/ghpages-react-redux-router-md.git

The fetch url is now https://github.com/RayBenefield/ghpages-react-redux-router-md.git because it is first in the list, and you can only have one. However the command git config --get remote.origin.url, now returns https://bitbucket.org/RayBenefield/ghpages-react-redux-router-md.git which results in gh-pages pushing to the gh-pages branch on Bitbucket.


Not sure of the best way to tackle this since this revolves around the git config command's functionality. If anything it may be helpful to notify that developer that the remote being pushed to is not actually Github. Took me a little bit to realize that it was pushing to Bitbucket's gh-pages rather than Github.

I figured I'd bring it up so everyone is aware. I'm fine with Bitbucket being my fetch for now for this particular project.

error: unknown option `--remove'

Is the version of this package that has the --remove option somehow not published to NPM? Version 0.11.0 doesn't seem to have it, I'm getting an error when I try to use it.

Move cache to install directory

Instead of adding a .gh-pages cache directory in the current working directory, the cache can go in the gh-pages installation directory.

cli --no-push not working?

It seems the --no-push option with the CLI doesn't work properly. Based on my tests, the commit is still pushed on origin.

Retain only specific directories when clearing

Mithril's official docs site uses this, but we always maintain an archive of all previous versions. We need to retain that directory (and only append to it), but we need to obliterate everything else when updating the site (hence this docs bug) to keep Google from erroneously seeing certain directories.

My "Updates" are not getting pushed

Hello.

I'm running gh-pages from my packages.json scripts section, setting up the -d option as follows: gh-pages -d src

Everything seems to be working fine as I'm getting the following in my console:

Cloning https://github.com/leog/leog.me.git into node_modules\gh-pages\.cache
Cleaning
Fetching origin
Checking out origin/gh-pages
Removing files
Copying files
Adding all
Committing
Pushing
Published

But actually, the commit was never pushed. Opening the .cache folder on my Git client, I can see the actual commit sitting there.

Am I forgetting something?

Thanks.

error is returned at undefined

Here is my launching code.

var done = new Promise( function(resolve,reject){

ghpages.publish(deploySrc, ghconfig[ghconfig.location],function(err,data){
             if(err !== null) {
               console.log('gh publish error:',err);
               return reject(err);}
             resolve(data);
     });

});  // end of promise

when run I get at the console gh publish error: undefined

it makes the cache file and pushes to repo despite the error although it's returning from the error before the push is complete.

Any way to tell what this error is?? or why it's coming back undefined.

of note
Just started yesterday. Initially I wasn't getting any error.
Just upped to node 5.3 yesterday. Using gh-pages 0.8.0

btw can(does) gh-pages return a promise? Looks like I saw you using q in the code.

How to handle archival builds with gh-pages?

I deploy the documentation sites of many of my projects through gh-pages. A while ago I realized that instead of nuking the whole site each time I publish, it would be nice to archive the old one below the previous version in the directory tree.

Is there some nice way to pull this off with gh-pages?

ignores

Support ignores, i.e., optionally respect .gitignore, .npmignore, a custom ignore file (e.g. .ghpagesignore), and/or a glob pattern(s) option.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.