Git Product home page Git Product logo

git-deploy's Introduction

Git Deploy

Bash script to automatically deploy repositories to local or remote environments when pushing a branch. Deployments are created using symbolic links named after their branch. Compatible with Linux and macOS.

Installation

You only need to install the script on systems on which you are planning to set up deployment remotes for a repository. The actual deployment process is handled by hooks within the remote environment.

Clone this repository into a temporary directory.

git clone https://github.com/lrdn/git-deploy.git

Create the required system directories should they not exist already.

sudo install -d -m 755 /usr/local/bin
sudo install -d -m 755 /usr/local/share/git-deploy/hooks

Place the executable script and deployment hooks in their respective directories.

sudo install -m 755 git-deploy/bin/git-deploy /usr/local/bin/git-deploy
sudo install -m 644 git-deploy/hooks/post-receive /usr/local/share/git-deploy/hooks/post-receive
sudo install -m 644 git-deploy/hooks/pre-receive /usr/local/share/git-deploy/hooks/pre-receive

Configuration

Enter your source repository to configure a deployment target specifying an environment and location. Environments are simply remotes and created automatically. The location can either be a local path or an SSH URL.

git deploy production ssh://[email protected]:/var/www/app

The setup routine will spawn an ssh-agent whenever you create a remote environment. Only public key authentication with the default identity is currently supported. You can however launch a custom shell instance beforehand which the setup will then use instead to establish the connection.

Deployment

Push an environment branch to deploy your application at the target location.

git push production master

Your application will be deployed using the symbolic link /var/www/app/production/master referencing the directory containing the actual commit work tree. This allows you to deploy branches individually within environments.

Build Automation

The deployment process can automatically perform build tasks by including a build.sh script within your repository. You can easily distinguish where the application was deployed to by checking the environment variables listed in the following example. This can be particularly useful to avoid accidental builds within your development environment.

#!/usr/bin/env bash

echo "GIT_DEPLOY_ID=${GIT_DEPLOY_ID}"
echo "GIT_DEPLOY_BRANCH=${GIT_DEPLOY_BRANCH}"
echo "GIT_DEPLOY_WORK_TREE=${GIT_DEPLOY_WORK_TREE}"
echo "GIT_DEPLOY_ENVIRONMENT=${GIT_DEPLOY_ENVIRONMENT}"

exit 0

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.