GithubHelp home page GithubHelp logo

abhishek199-dhn / deploy-to-git Goto Github PK

View Code? Open in Web Editor NEW

This project forked from finom/deploy-to-git

0.0 1.0 0.0 81 KB

Deploy build artifacts to a Git repository

License: MIT License

JavaScript 100.00%

deploy-to-git's Introduction

deploy-to-git npm version Build Status

Automatically or manually deploy build artifacts to a Git repository. The tool works awesome with semantic-release and any CI service.

npm install --save-dev deploy-to-git

Configuring

Configuration for the tool needs to be placed at config.deployToGit object inside package.json.

  • repository - a repository
  • branch - a branch of the repository where you want to push the artifacts
  • folder - a folder where artifacts are generated by the build and where the repository is cloned
  • script - a script which runs the build
  • commit - commit text
  • user - commitee information for Git - an object with keys name and email
  • beforePushScript (optional) - a command that should be run after a commit (e. g. add needed git tags).

Substrings started with $ are replaced by corresponding environment variables.

Getting started

Let's say you want to deploy artifacts to branch called artifacts. Let's say used build tool compiles the artifacts to build folder via NPM script called build-my-app. You'll need:

  1. Create artifacts branch manually and remove all files from it (because you probably create the branch copying main branch contents). Push it to remote repository.
  2. Add README or whatever you want to have at this branch.
  3. Add build folder to .gitignore of your main branch.
  4. Configure deploy-to-git
"scripts": {
  "deploy": "deploy-to-git",
  "build-my-app": "a-build-script"
}
"config": {
  "deployToGit": {
      "repository": "[email protected]:owner/your-repo.git",
      "branch": "artifacts",
      "folder": "build",
      "script": "npm run build-my-app",
      "commit": "Automatic commit text",
      "user": {
          "email": "[email protected]",
          "name": "Your name"
      }
  }
}

That's it. When you run npm run deploy the tool does the following:

  1. Clone the repository to build folder.
  2. Run script npm run build-my-app which creates/replaces files at build folder.
  3. Commit and push changes.

Tip: remove build folder before deploy-to-git run.

For more info check out index.js.

Travis CI

To run it on Travis CI use the following format of repository field: https://[email protected]/owner/your-repo.git. You can generate GH_TOKEN at Github settings and add it to Travis CI manually. For more info just google it ("generate github token", "add environment variable to Travis") :)

It is generated automatically if you use semantic-release-cli.

semantic-release

Just add deploy-to-github to semantic-release script.

"deploy": "deploy-to-git",
"semantic-release": "semantic-release pre && npm run deploy && npm publish && semantic-release post",

Tip: You can use a release version in a commit message:

"commit": "Publising $npm_package_version",

Real example

Real example can be found there. The application is compiled via webpack to bundle folder and pushed to gh-pages branch.

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.