npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

deploy-to-git

v0.4.1

Published

Automatically deploy build artifacts to a Git repository

Downloads

187

Readme

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.