Skip to content

Instantly share code, notes, and snippets.

@jayshreeanand
Forked from abhionlyone/Capfile
Created August 19, 2020 19:02
Show Gist options
  • Select an option

  • Save jayshreeanand/ab8a3837adcd7e7461e1c0759685501c to your computer and use it in GitHub Desktop.

Select an option

Save jayshreeanand/ab8a3837adcd7e7461e1c0759685501c to your computer and use it in GitHub Desktop.

Revisions

  1. @abhionlyone abhionlyone revised this gist May 24, 2018. No changes.
  2. @abhionlyone abhionlyone created this gist May 24, 2018.
    6 changes: 6 additions & 0 deletions Capfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    require "capistrano/setup"
    require "capistrano/deploy"
    require "capistrano/scm/git"
    require 'capistrano/npm'
    install_plugin Capistrano::SCM::Git
    Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
    7 changes: 7 additions & 0 deletions Gemfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    # frozen_string_literal: true
    source "https://rubygems.org"

    git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

    gem 'capistrano', '~> 3.10', '>= 3.10.2'
    gem 'capistrano-npm'
    18 changes: 18 additions & 0 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    # config/deploy.rb

    # config valid for current version and patch releases of Capistrano
    lock "~> 3.10.2"

    set :application, "app-name"
    set :repo_url, "[email protected]:username/app-name.git"
    set :ssh_options, { :forward_agent => true }
    set :npm_flags, '--silent --no-progress'

    namespace :deploy do
    desc 'Restart application'
    task :restart do
    invoke 'react:build'
    end
    end

    after 'deploy:publishing', 'deploy:restart'
    10 changes: 10 additions & 0 deletions react.rake
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # lib/capistrano/tasks/react.rake
    namespace :react do
    desc 'RUN NPM BUILD'
    task :build do
    on roles(:app) do
    execute "sh -c \"cd #{deploy_to}/current/ && #{fetch(:build_command)}\""
    end
    end
    end

    8 changes: 8 additions & 0 deletions staging.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    # config/deploy/staging.rb

    set :branch, 'staging'
    set :deploy_to, 'path_to_staging'

    server 'your-server-ip-here', user: 'user', port: 22, roles: %w{web app db}

    set :build_command, 'npm run build'