capistrano-craft 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +38 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +3 -0
- data/capistrano-craft.gemspec +29 -0
- data/lib/capistrano/craft.rb +15 -0
- data/lib/capistrano/craft/craft.rb +3 -0
- data/lib/capistrano/craft/defaults.rb +24 -0
- data/lib/capistrano/craft/version.rb +5 -0
- data/lib/capistrano/dsl/craft.rb +103 -0
- data/lib/capistrano/tasks/craft.rake +52 -0
- data/lib/capistrano/tasks/db.rake +69 -0
- data/lib/capistrano/tasks/deploy.rake +17 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: '09f776fa507f01ebc0ba95804640d29136b275a1'
|
4
|
+
data.tar.gz: 5117c84753e343bbf86dacaf7730d61fe2daf2e4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0255aadbcfd907b73a5bed129038f64315dbab38b44f721002c9807f854960ac1a106b0553eebf3b7bbd612716a85c8c49b6aabc8214728c8bedf19c865e2277
|
7
|
+
data.tar.gz: feecf14faf1ca427911734b386f42c67ffbcc0158b1da3a1cad3b013e4ba41827af72d3dc0b0ced8cf7490958a344e1c8a6279b53297dbabacdc8620704c7190
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at chrisdyer1@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
capistrano-craft (0.1.0)
|
5
|
+
capistrano (~> 3.1)
|
6
|
+
capistrano-composer (~> 0.0.6)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
airbrussh (1.4.0)
|
12
|
+
sshkit (>= 1.6.1, != 1.7.0)
|
13
|
+
capistrano (3.11.2)
|
14
|
+
airbrussh (>= 1.0.0)
|
15
|
+
i18n
|
16
|
+
rake (>= 10.0.0)
|
17
|
+
sshkit (>= 1.9.0)
|
18
|
+
capistrano-composer (0.0.6)
|
19
|
+
capistrano (>= 3.0.0.pre)
|
20
|
+
concurrent-ruby (1.1.5)
|
21
|
+
i18n (1.7.0)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
net-scp (2.0.0)
|
24
|
+
net-ssh (>= 2.6.5, < 6.0.0)
|
25
|
+
net-ssh (5.2.0)
|
26
|
+
rake (13.0.0)
|
27
|
+
sshkit (1.20.0)
|
28
|
+
net-scp (>= 1.1.2)
|
29
|
+
net-ssh (>= 2.8.0)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
capistrano-craft!
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Chris Dyer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Capistrano::Craft
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/capistrano/craft`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'capistrano-craft'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install capistrano-craft
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/capistrano-craft. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Capistrano::Craft project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/capistrano-craft/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "capistrano/craft/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "capistrano-craft"
|
7
|
+
spec.version = Capistrano::Craft::VERSION
|
8
|
+
spec.authors = ["Chris Dyer"]
|
9
|
+
spec.email = ["chris@cdyer.co.uk"]
|
10
|
+
|
11
|
+
spec.summary = %q{Capistrano Craft - Easy deployment of Symfony 4 apps with Ruby over SSH}
|
12
|
+
spec.description = %q{Craft CMS specific Capistrano tasks}
|
13
|
+
spec.homepage = "https://github.com/dyerc/capistrano-craft"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/dyerc/capistrano-craft"
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_dependency 'capistrano', '~> 3.1'
|
28
|
+
spec.add_dependency 'capistrano-composer', '~> 0.0.6'
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "capistrano/dsl/craft"
|
2
|
+
self.extend Capistrano::DSL::Craft
|
3
|
+
|
4
|
+
SSHKit::Backend::Netssh.send(:include, Capistrano::DSL::Craft)
|
5
|
+
SSHKit::Backend::Local.send(:include, Capistrano::DSL::Craft)
|
6
|
+
|
7
|
+
require "capistrano/composer"
|
8
|
+
require "capistrano/craft/craft"
|
9
|
+
require "capistrano/craft/version"
|
10
|
+
|
11
|
+
namespace :load do
|
12
|
+
task :defaults do
|
13
|
+
load "capistrano/craft/defaults.rb"
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#
|
2
|
+
# Craft CMS defaults
|
3
|
+
#
|
4
|
+
|
5
|
+
set :config_path, "config"
|
6
|
+
set :php, "php"
|
7
|
+
|
8
|
+
set :craft_local_env, -> { "#{Dir.pwd}/.env" }
|
9
|
+
set :craft_remote_env, -> { "#{fetch(:deploy_to)}/shared/.env" }
|
10
|
+
|
11
|
+
set :craft_local_db_dump, "db.sql"
|
12
|
+
set :craft_local_backups, "backups"
|
13
|
+
set :craft_remote_backups, "shared/backups"
|
14
|
+
|
15
|
+
# assets
|
16
|
+
set :craft_compile_assets, "npm run production --production --silent"
|
17
|
+
|
18
|
+
# console
|
19
|
+
set :craft_console_path, -> { "craft" }
|
20
|
+
set :craft_console_flags, ""
|
21
|
+
|
22
|
+
# Role filtering
|
23
|
+
set :craft_roles, :all
|
24
|
+
set :craft_deploy_roles, :all
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Capistrano
|
2
|
+
module DSL
|
3
|
+
module Craft
|
4
|
+
def craft_app_path
|
5
|
+
release_path.join(fetch(:app_path))
|
6
|
+
end
|
7
|
+
|
8
|
+
def craft_console_path
|
9
|
+
release_path.join(fetch(:craft_console_path))
|
10
|
+
end
|
11
|
+
|
12
|
+
def craft_console(command, params = '')
|
13
|
+
on release_roles(fetch(:craft_deploy_roles)) do
|
14
|
+
execute fetch(:php), craft_console_path, command, params, fetch(:craft_console_flags)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def confirm(question)
|
19
|
+
set :confirmed, proc {
|
20
|
+
puts <<-EOF
|
21
|
+
|
22
|
+
************************** WARNING ***************************
|
23
|
+
#{question}
|
24
|
+
**************************************************************
|
25
|
+
|
26
|
+
EOF
|
27
|
+
ask :answer, "y/N"
|
28
|
+
if fetch(:answer).strip == 'y' then true else false end
|
29
|
+
}.call
|
30
|
+
|
31
|
+
unless fetch(:confirmed)
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Database
|
37
|
+
|
38
|
+
def backup_file_name
|
39
|
+
now = Time.now
|
40
|
+
backup_date = [now.year, now.strftime("%m"), now.strftime("%d")]
|
41
|
+
backup_time = [now.strftime("%H"), now.strftime("%M"), now.strftime("%S")]
|
42
|
+
|
43
|
+
unless Dir.exist?(fetch(:craft_local_backups))
|
44
|
+
Dir.mkdir(fetch(:craft_local_backups))
|
45
|
+
end
|
46
|
+
|
47
|
+
File.join(fetch(:craft_local_backups), "#{backup_date.join('-')}_#{backup_time.join('-')}.sql")
|
48
|
+
end
|
49
|
+
|
50
|
+
def postgres_dump(env, output)
|
51
|
+
execute SSHKit::Command.new <<-EOCOMMAND
|
52
|
+
source "#{env}"
|
53
|
+
PGPASSWORD=$DB_PASSWORD pg_dump -U $DB_USER -h $DB_SERVER -p $DB_PORT -F p --no-owner $DB_DATABASE > #{output}
|
54
|
+
EOCOMMAND
|
55
|
+
end
|
56
|
+
|
57
|
+
def mysql_dump(env, output)
|
58
|
+
end
|
59
|
+
|
60
|
+
def postgres_restore(env, input)
|
61
|
+
execute SSHKit::Command.new <<-EOCOMMAND
|
62
|
+
source "#{env}"
|
63
|
+
PGPASSWORD=$DB_PASSWORD dropdb -U $DB_USER -h $DB_SERVER -p $DB_PORT $DB_DATABASE
|
64
|
+
PGPASSWORD=$DB_PASSWORD createdb -U $DB_USER -h $DB_SERVER -p $DB_PORT $DB_DATABASE
|
65
|
+
PGPASSWORD=$DB_PASSWORD psql -U $DB_USER -d $DB_DATABASE -h $DB_SERVER -p $DB_PORT -q < "#{input}"
|
66
|
+
EOCOMMAND
|
67
|
+
end
|
68
|
+
|
69
|
+
def mysql_restore(env, input)
|
70
|
+
end
|
71
|
+
|
72
|
+
def craft_database(env)
|
73
|
+
driver = capture SSHKit::Command.new <<-EOCOMMAND
|
74
|
+
source "#{env}"
|
75
|
+
echo $DB_DRIVER
|
76
|
+
EOCOMMAND
|
77
|
+
|
78
|
+
case driver.strip
|
79
|
+
when "pgsql" then return :pgsql
|
80
|
+
when "mysql" then return :mysql
|
81
|
+
else
|
82
|
+
raise "Unable to determine remote server database driver"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def database_dump(env, input)
|
87
|
+
if craft_database(env) == :pgsql
|
88
|
+
postgres_dump(env, input)
|
89
|
+
else
|
90
|
+
mysql_dump(env, input)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def database_restore(env, input)
|
95
|
+
if craft_database(env) == :pgsql
|
96
|
+
postgres_restore(env, input)
|
97
|
+
else
|
98
|
+
mysql_restore(env, input)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
namespace :craft do
|
2
|
+
|
3
|
+
desc "Ensure folder permissions are correct"
|
4
|
+
task :set_permissions do
|
5
|
+
on release_roles(fetch(:craft_deploy_roles)) do
|
6
|
+
within release_path do
|
7
|
+
# https://docs.craftcms.com/v3/installation.html#step-2-set-the-file-permissions
|
8
|
+
|
9
|
+
execute "chmod 744 .env"
|
10
|
+
execute "chmod 744 composer.json"
|
11
|
+
execute "chmod 744 composer.lock"
|
12
|
+
execute "chmod 744 config/license.key"
|
13
|
+
execute "chmod -R 744 storage/*"
|
14
|
+
execute "chmod -R 744 vendor/*"
|
15
|
+
execute "chmod -R 744 web/cpresources/*"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
namespace :cache do
|
21
|
+
task :clear do
|
22
|
+
on release_roles(fetch(:craft_deploy_roles)) do
|
23
|
+
craft_console "cache/flush"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
namespace :assets do
|
29
|
+
desc "Synchronise assets between local and remote server"
|
30
|
+
task :sync do
|
31
|
+
run_locally do
|
32
|
+
on release_roles(fetch(:craft_deploy_roles)) do
|
33
|
+
puts "User -> " + role.user
|
34
|
+
execute :rsync, "-vzO #{role.user}@#{role.hostname}:#{shared_path}/web/assets/ web/assets"
|
35
|
+
execute :rsync, "-vzO web/assets/ #{role.user}@#{role.hostname}:#{shared_path}/web/assets"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Pull database and sync assets"
|
42
|
+
task :pull do
|
43
|
+
invoke "db:pull"
|
44
|
+
invoke "craft:sync_assets"
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Push database and sync assets"
|
48
|
+
task :push do
|
49
|
+
invoke "db:push"
|
50
|
+
invoke "craft:sync_assets"
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
namespace :db do
|
2
|
+
namespace :local do
|
3
|
+
desc "Export the local database to craft_local_db_dump (db.sql)"
|
4
|
+
task :backup do
|
5
|
+
run_locally do
|
6
|
+
database_dump(fetch(:craft_local_env), fetch(:craft_local_db_dump))
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Import into the local database from craft_local_db_dump (db.sql)"
|
11
|
+
task :import do
|
12
|
+
run_locally do
|
13
|
+
database_restore(fetch(:craft_local_env), fetch(:craft_local_db_dump))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Download a backup of the remote database"
|
19
|
+
task :backup do
|
20
|
+
on release_roles(fetch(:craft_deploy_roles)) do
|
21
|
+
# Export remote dump file
|
22
|
+
backup_file = "#{fetch(:deploy_to)}/shared/db.sql"
|
23
|
+
database_dump(fetch(:craft_remote_env), backup_file)
|
24
|
+
|
25
|
+
download! backup_file, backup_file_name
|
26
|
+
|
27
|
+
# Remove temp file
|
28
|
+
execute "rm #{backup_file}"
|
29
|
+
|
30
|
+
set :backup_filename, backup_file_name
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Imports the remote database into the local environment"
|
35
|
+
task :pull do
|
36
|
+
invoke 'db:backup'
|
37
|
+
|
38
|
+
on release_roles(fetch(:craft_deploy_roles)) do
|
39
|
+
database_restore(fetch(:craft_local_env), fetch(:backup_filename))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Export the local database, overwriting the remote server"
|
44
|
+
task :push do
|
45
|
+
# Save the remote database
|
46
|
+
invoke 'db:backup'
|
47
|
+
|
48
|
+
# Save the local database
|
49
|
+
invoke 'db:local:backup'
|
50
|
+
|
51
|
+
on release_roles(fetch(:craft_deploy_roles)) do
|
52
|
+
# Upload local dump file
|
53
|
+
uploaded_file = "#{fetch(:deploy_to)}/shared/db.sql"
|
54
|
+
upload! fetch(:craft_local_db_dump), uploaded_file
|
55
|
+
|
56
|
+
confirm <<-EOF
|
57
|
+
Are you sure you want to drop and recreate the remote database?
|
58
|
+
|
59
|
+
A backup of the remote database has been taken in the file #{fetch(:backup_filename)} but you should verify this is correct before proceeding.
|
60
|
+
EOF
|
61
|
+
|
62
|
+
# Import into production
|
63
|
+
database_restore(fetch(:craft_remote_env), uploaded_file)
|
64
|
+
|
65
|
+
# Remove temp file
|
66
|
+
execute "rm #{uploaded_file}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
namespace :deploy do
|
2
|
+
task :updating do
|
3
|
+
invoke "craft:set_permissions"
|
4
|
+
end
|
5
|
+
|
6
|
+
desc 'Compile assets'
|
7
|
+
task :compile_assets do
|
8
|
+
on release_roles(fetch(:craft_deploy_roles)) do
|
9
|
+
within release_path do
|
10
|
+
execute :npm, "install", "--production", "--silent"
|
11
|
+
execute fetch(:craft_compile_assets)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
after 'deploy:updated', 'deploy:compile_assets'
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-craft
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Dyer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: capistrano-composer
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.6
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.6
|
41
|
+
description: Craft CMS specific Capistrano tasks
|
42
|
+
email:
|
43
|
+
- chris@cdyer.co.uk
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- CODE_OF_CONDUCT.md
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- capistrano-craft.gemspec
|
56
|
+
- lib/capistrano/craft.rb
|
57
|
+
- lib/capistrano/craft/craft.rb
|
58
|
+
- lib/capistrano/craft/defaults.rb
|
59
|
+
- lib/capistrano/craft/version.rb
|
60
|
+
- lib/capistrano/dsl/craft.rb
|
61
|
+
- lib/capistrano/tasks/craft.rake
|
62
|
+
- lib/capistrano/tasks/db.rake
|
63
|
+
- lib/capistrano/tasks/deploy.rake
|
64
|
+
homepage: https://github.com/dyerc/capistrano-craft
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata:
|
68
|
+
homepage_uri: https://github.com/dyerc/capistrano-craft
|
69
|
+
source_code_uri: https://github.com/dyerc/capistrano-craft
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.6.14.3
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Capistrano Craft - Easy deployment of Symfony 4 apps with Ruby over SSH
|
90
|
+
test_files: []
|