-
-
Save jayshreeanand/ab8a3837adcd7e7461e1c0759685501c to your computer and use it in GitHub Desktop.
create-react-app with capistrano for automated deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment