Skip to content

Instantly share code, notes, and snippets.

@jaywilliams
Forked from rg-najera/deploy.rb
Last active July 11, 2022 00:32
Show Gist options
  • Select an option

  • Save jaywilliams/c0abbec89ef6bc81cb49 to your computer and use it in GitHub Desktop.

Select an option

Save jaywilliams/c0abbec89ef6bc81cb49 to your computer and use it in GitHub Desktop.

Revisions

  1. jaywilliams revised this gist May 1, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion deploy.rb
    Original file line number Diff line number Diff line change
    @@ -104,4 +104,4 @@
    task assets: %w(compile copy)
    end

    after 'deploy:publishing', 'deploy:assets'
    after 'deploy:updated', 'deploy:assets'
  2. jaywilliams revised this gist May 1, 2015. 1 changed file with 21 additions and 22 deletions.
    43 changes: 21 additions & 22 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -71,38 +71,37 @@
    # Uncomment the following line to run it on deploys if needed
    # after 'deploy:publishing', 'deploy:update_option_paths'

    # Global bedrock theme path
    set :theme_path, Pathname.new('web/app/themes').join(fetch(:theme_name))

    # Local Paths
    set :local_app_path, Pathname.new(File.dirname(__FILE__)).join('../')
    set :local_theme_path, fetch(:local_app_path).join(fetch(:theme_path))
    set :local_dist_path, fetch(:local_theme_path).join('dist')
    # Remote Paths
    set :remote_theme_path, release_path.join(fetch(:theme_path))
    set :remote_dist_path, fetch(:remote_theme_path).join('dist')

    namespace :assets do
    namespace :deploy do

    # Theme path
    set :theme_path, Pathname.new('web/app/themes').join(fetch(:theme_name))

    # Local Paths
    set :local_theme_path, Pathname.new(File.dirname(__FILE__)).join('../').join(fetch(:theme_path))
    set :local_dist_path, fetch(:local_theme_path).join('dist')

    task :compile do
    run_locally do
    within fetch(:local_theme_path) do
    execute :gulp, '--production'
    end
    end
    end

    task :copy do
    on roles(:web) do
    ld = fetch(:local_dist_path)
    rd = fetch(:remote_dist_path)
    info " Your local distribution path: #{ld} "
    info " Boom!!! Your remote distribution path: #{rd} "
    info " Uploading files to remote "

    # Remote Paths (Lazy-load until actual deploy)
    set :remote_dist_path, -> { release_path.join(fetch(:theme_path)).join('dist') }

    info " Your local distribution path: #{fetch(:local_dist_path)} "
    info " Boom!!! Your remote distribution path: #{fetch(:remote_dist_path)} "
    info " Uploading files to remote "
    upload! fetch(:local_dist_path).to_s, fetch(:remote_dist_path), recursive: true
    end
    end
    task deploy: %w(compile copy)

    task assets: %w(compile copy)
    end
    after 'deploy:published', 'assets:deploy'

    after 'deploy:publishing', 'deploy:assets'
  3. Rodrigo Garcia revised this gist Apr 24, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion deploy.rb
    Original file line number Diff line number Diff line change
    @@ -105,4 +105,4 @@
    task deploy: %w(compile copy)
    end

    before 'deploy:updated', 'assets:deploy'
    after 'deploy:published', 'assets:deploy'
  4. Rodrigo Garcia revised this gist Apr 3, 2015. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,3 @@
    require 'dotenv'
    Dotenv.load

    set :repo_url, '[email protected]:Design-Collective/some-repo.git'
    set :application, 'the-app-name.com'
    set :theme_name, 'sage'
    @@ -78,8 +75,7 @@
    set :theme_path, Pathname.new('web/app/themes').join(fetch(:theme_name))

    # Local Paths
    set :local_sites_path, Pathname.new(ENV["DEV_LOCAL_SITES_PATH"])
    set :local_app_path, fetch(:local_sites_path).join(fetch(:application))
    set :local_app_path, Pathname.new(File.dirname(__FILE__)).join('../')
    set :local_theme_path, fetch(:local_app_path).join(fetch(:theme_path))
    set :local_dist_path, fetch(:local_theme_path).join('dist')
    # Remote Paths
  5. sugarskull created this gist Apr 3, 2015.
    112 changes: 112 additions & 0 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,112 @@
    require 'dotenv'
    Dotenv.load

    set :repo_url, '[email protected]:Design-Collective/some-repo.git'
    set :application, 'the-app-name.com'
    set :theme_name, 'sage'

    # Branch options
    # Prompts for the branch name (defaults to current branch)
    #ask :branch, -> { `git rev-parse --abbrev-ref HEAD`.chomp }

    # Hardcodes branch to always be master
    # This could be overridden in a stage config file

    set :deploy_to, -> { "/srv/www/#{fetch(:application)}" }

    # Use :debug for more verbose output when troubleshooting
    set :log_level, :debug

    # Apache users with .htaccess files:
    # it needs to be added to linked_files so it persists across deploys:
    # set :linked_files, fetch(:linked_files, []).push('.env', 'web/.htaccess')
    set :linked_files, fetch(:linked_files, []).push('.env')
    set :linked_dirs, fetch(:linked_dirs, []).push('web/app/uploads')

    namespace :deploy do
    desc 'Restart application'
    task :restart do
    on roles(:app), in: :sequence, wait: 5 do
    # Your restart mechanism here, for example:
    execute :service, :nginx, :reload
    end
    end
    end

    # The above restart task is not run by default
    # Uncomment the following line to run it on deploys if needed
    # after 'deploy:publishing', 'deploy:restart'

    namespace :composer do
    #before 'install', 'change_dir'

    #desc 'Composer update'
    #task :change_dir do
    #on roles(:app) do
    #execute "cd #{release_path}/ && composer update"
    #end
    #end
    end

    namespace :deploy do
    desc 'Update WordPress template root paths to point to the new release'
    task :update_option_paths do
    on roles(:app) do
    within fetch(:release_path) do
    if test :wp, :core, 'is-installed'
    [:stylesheet_root, :template_root].each do |option|
    # Only change the value if it's an absolute path
    # i.e. The relative path "/themes" must remain unchanged
    # Also, the option might not be set, in which case we leave it like that
    value = capture :wp, :option, :get, option, raise_on_non_zero_exit: false
    if value != '' && value != '/themes'
    execute :wp, :option, :set, option, fetch(:release_path).join('web/wp/wp-content/themes')
    end
    end
    end
    end
    end
    end
    end

    # The above update_option_paths task is not run by default
    # Note that you need to have WP-CLI installed on your server
    # Uncomment the following line to run it on deploys if needed
    # after 'deploy:publishing', 'deploy:update_option_paths'

    # Global bedrock theme path
    set :theme_path, Pathname.new('web/app/themes').join(fetch(:theme_name))

    # Local Paths
    set :local_sites_path, Pathname.new(ENV["DEV_LOCAL_SITES_PATH"])
    set :local_app_path, fetch(:local_sites_path).join(fetch(:application))
    set :local_theme_path, fetch(:local_app_path).join(fetch(:theme_path))
    set :local_dist_path, fetch(:local_theme_path).join('dist')
    # Remote Paths
    set :remote_theme_path, release_path.join(fetch(:theme_path))
    set :remote_dist_path, fetch(:remote_theme_path).join('dist')

    namespace :assets do
    task :compile do
    run_locally do
    within fetch(:local_theme_path) do
    execute :gulp, '--production'
    end
    end
    end

    task :copy do
    on roles(:web) do
    ld = fetch(:local_dist_path)
    rd = fetch(:remote_dist_path)
    info " Your local distribution path: #{ld} "
    info " Boom!!! Your remote distribution path: #{rd} "
    info " Uploading files to remote "
    upload! fetch(:local_dist_path).to_s, fetch(:remote_dist_path), recursive: true
    end
    end

    task deploy: %w(compile copy)
    end

    before 'deploy:updated', 'assets:deploy'