@julmot/git-branch-deploy

1.0.1 • Public • Published

Git Branch Deploy

A Node.js tool to deploy build artifacts to a GitHub branch using a Git commit.

Installation

$ npm i @julmot/git-branch-deploy

Deployment

const deploy = require('@julmot/git-branch-deploy');

deploy({
  branch: 'website', // Name of the target branch
  sourceDir: `${__dirname}/library/`, // Folder where the build artifacts are located
  deployDir: `${__dirname}/deploy/`, // Build folder where the GitHub repository can be cloned to
  gitName: process.env.GIT_USER_NAME, // The name that should appear in the Git commit
  gitEmail: process.env.GIT_USER_EMAIL, // The e-mail address to use in the Git commit
  ghRepository: process.env.GITHUB_REPOSITORY, // The GitHub repository URL, e.g. https://github.com/julmot/git-branch-deploy
  ghUser: process.env.GITHUB_USERNAME, // The GitHub username of the account with which the commit should be pushed
  ghToken: process.env.GITHUB_TOKEN, // A GitHub private access key of the account with which the commit should be pushed
  travis: true // Makes sure the deployment only succeeds when running on Travis CI
});

The above mentioned values are the default values, except:

  • branch
  • sourceDir
  • deployDir

which must be provided (no default values). So, the minimal example would be:

deploy({
  branch: 'website',
  sourceDir: `${__dirname}/library/`,
  deployDir: `${__dirname}/deploy/`
});

NOTE: Make sure that the target branch in the repository exists on GitHub. To create an empty branch you can use these instructions.

Readme

Keywords

Package Sidebar

Install

npm i @julmot/git-branch-deploy

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

5.58 kB

Total Files

5

Last publish

Collaborators

  • julmot