Sha256: 4835424a00b8c8ff4c3c29fadb73d113f40ae27de54fbe6121682508a9e7e4bf

Contents?: true

Size: 1.87 KB

Versions: 50

Compression:

Stored size: 1.87 KB

Contents

#!/bin/bash

#/ NAME
#/     remote-helper -- remotely builds a workarea
#/
#/ SYNOPSIS
#/     
#/     remote-heper deployer git_url git_spec deploy_comand deploy_args
#/

set -e

# figure out the project root under which bin, lib live
shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"

fl_debug=

function crumb {
  if [[ -n "$fl_debug" ]]; then
    echo "$(date) $@" 1>&2
  fi
}

# entry point
function main {
  nm_deployer=$1; shift
  git_url=$1; shift
  git_spec=$1; shift
  cmd_deploy=$1; shift

  if [[ "$cmd_deploy" = "debug" ]]; then
    fl_debug=1
  fi

  crumb "start remote-helper with args: $nm_deployer, $git_url, $git_spec, $cmd_deploy"
  crumb "additional args: $@"

  git_branch="${git_spec%%:*}"
  git_sha="${git_spec##*:}"

  crumb "derive: git_branch = $git_branch"
  crumb "derive: git_sha = $git_sha"

  mkdir -p "$HOME/.deploy/$nm_deployer"
  cd "$HOME/.deploy/$nm_deployer"

  nm_project=$(basename $git_url .git)
  if [[ ! -d $nm_project ]]; then
    crumb "git clone $git_url"
    git clone -q $git_url
  fi
  crumb "remote deploy on ${LOGNAME}@$(hostname) in $HOME/.deploy/$nm_deployer/$nm_project/"

  cd $nm_project
  git fetch -q

  if [[ -z $git_branch || $git_branch = $git_sha ]]; then
    crumb "git reset, checkout of $git_sha"
    git reset -q --hard $git_sha
    git checkout -q $git_sha
  else
    crumb "git checkout of $git_branch, reset of $git_sha"
    git checkout -q --force $git_branch
    git reset -q --hard $git_sha
  fi

  crumb "git submodule"
  git submodule -q update --init --recursive

  crumb "executing ao $cmd_deploy $@"
  export _AO_DEPLOYER="$nm_deployer"
  bundle check 2>&1 >/dev/null || { bundle install --quiet --local --path vendor/bundle || bundle check > /dev/null; }
  bundle exec ao $cmd_deploy "$@"
  crumb "end remote-helper"
}

# setup
unset cd # disable rvm's cd function to prevent prompts

# pass arguments to entry point
main "$@"

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
alpha_omega-1.3.29 sbin/remote-helper
alpha_omega-1.3.28 sbin/remote-helper
alpha_omega-1.3.27 sbin/remote-helper
alpha_omega-1.3.26 sbin/remote-helper
alpha_omega-1.3.25 sbin/remote-helper
alpha_omega-1.3.24 sbin/remote-helper
alpha_omega-1.3.23 sbin/remote-helper
alpha_omega-1.3.22 sbin/remote-helper
alpha_omega-1.3.21 sbin/remote-helper
alpha_omega-1.3.20 sbin/remote-helper
alpha_omega-1.3.19 sbin/remote-helper
alpha_omega-1.3.18 sbin/remote-helper
alpha_omega-1.3.17 sbin/remote-helper
alpha_omega-1.3.16 sbin/remote-helper
alpha_omega-1.3.15 sbin/remote-helper
alpha_omega-1.3.14 sbin/remote-helper
alpha_omega-1.3.12 sbin/remote-helper
alpha_omega-1.3.11 sbin/remote-helper
alpha_omega-1.3.10 sbin/remote-helper
alpha_omega-1.4.1 sbin/remote-helper