{"id":14968607,"url":"https://github.com/antistatique/capdrupal","last_synced_at":"2025-05-08T21:25:34.403Z","repository":{"id":8951623,"uuid":"10688466","full_name":"antistatique/capdrupal","owner":"antistatique","description":"Capistrano recipies for Drupal 10, Drupal 9, Drupal 8 and Drupal 7","archived":false,"fork":false,"pushed_at":"2024-03-01T07:59:37.000Z","size":129,"stargazers_count":50,"open_issues_count":10,"forks_count":14,"subscribers_count":29,"default_branch":"main","last_synced_at":"2025-02-02T03:51:15.600Z","etag":null,"topics":["automation","capistrano","deployment","drupal","drupal-10","drupal-7","drupal-8","drupal-9","ruby"],"latest_commit_sha":null,"homepage":"http://rubygems.org/gems/capdrupal","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ParsePlatform/docs","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antistatique.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-06-14T12:28:27.000Z","updated_at":"2023-12-16T00:23:31.000Z","dependencies_parsed_at":"2024-03-01T08:42:56.989Z","dependency_job_id":null,"html_url":"https://github.com/antistatique/capdrupal","commit_stats":{"total_commits":59,"total_committers":4,"mean_commits":14.75,"dds":0.288135593220339,"last_synced_commit":"98dbe30e44ff48d2f9e9c6bd0f75fa378760b9c9"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antistatique%2Fcapdrupal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antistatique%2Fcapdrupal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antistatique%2Fcapdrupal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antistatique%2Fcapdrupal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antistatique","download_url":"https://codeload.github.com/antistatique/capdrupal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238044095,"owners_count":19407128,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","capistrano","deployment","drupal","drupal-10","drupal-7","drupal-8","drupal-9","ruby"],"created_at":"2024-09-24T13:40:17.699Z","updated_at":"2025-02-10T02:09:46.247Z","avatar_url":"https://github.com/antistatique.png","language":"Ruby","readme":"# Capdrupal\n\nThis gem provides a number of tasks which are useful for deploying \u0026 managing Drupal projects with [Capistrano](https://github.com/capistrano/capistrano).\n\n[![Gem Version](https://badge.fury.io/rb/capdrupal.svg)](https://badge.fury.io/rb/capdrupal)\n[![Maintainability](https://api.codeclimate.com/v1/badges/e5db5a7f49d86ce5e418/maintainability)](https://codeclimate.com/github/antistatique/capdrupal/maintainability)\n\n# Capdrupal version\n\nCapdrupal Gem Version | Branch | Capistrano Version | Drupal Version\n--------------------- | ------ | ------------------ | --------------\n0.11.0                | d7     | 2                  | 7.x\n3.x                   | main   | 3.x                | 8.x\n3.x                   | main   | 3.x                | 9.x\n3.x                   | main   | 3.x                | 10.x\n\n## Prerequisites\n\nBy default, Capdrupal will use **Drush** to run every Drupal commands. Therefore, your Drupal project **must** to require \n`drush/drush`.\n\nYou may add Drush as a dependency using `composer require drush/drush` in your Drupal project. Read more at [drush/drush](https://github.com/drush-ops/drush).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'capdrupal', '~\u003e3.0'\n```\n\nAnd then execute:\n\n```shell\nbundle\n```\n\nOr install it yourself if [gems](http://rubygems.org) is installed on your system:\n\n```shell\ngem install capdrupal\n```\n\n## Configuration\n\nFirst, go to your project directory and launch Capistrano.\n\n```shell\ncd path/to/your/drupal/project/\ncap install\n```\n\nCapistrano will create the following skeleton\n\n```\n.\n├── Capfile\n├── config\n│   └── deploy.rb\n│   └── deploy\n│       └── production.rb\n│       └── staging.rb\n├── lib\n│   └── capistrano\n│        └── tasks\n\n```\n\nCreate two files `Capfile` and `config/deploy.rb`. Open `Capfile` and set the dependencies.\n\n```ruby\n# Load DSL and set up stages.\nrequire 'capistrano/setup'\n\n# Include default deployment tasks.\nrequire 'capistrano/deploy'\n\n# Composer is needed to install drush on the server.\nrequire 'capistrano/composer'\n\n# Drupal Tasks.\nrequire 'capdrupal'\n\n# Load custom tasks from `lib/capistrano/tasks` if you have any defined.\nDir.glob('config/capistrano/tasks/*.rake').each { |r| import r }\n```\n\nThen, go to `config/deploy.rb` to set the parameters of your project. First you have to define the general information about the user, server and the app himself.\n\n```ruby\nset :application, 'application-name'\nset :repo_url, 'git@github.com:company/application.git'\n\nserver 'ssh.example.org', user: 'username', roles: %w{app db web}\n```\n\nThe specific Drupal information\n\n```ruby\nset :install_composer, true\nset :install_drush, true\n\nset :app_path, 'web'\nset :config_path, 'config/sync'\n\n# Setup the backup before/after failed strategy.\nset :backup_path, 'backups'\nset :keep_backups, 5\n\n# Link file settings.php\nset :linked_files, fetch(:linked_files, []).push(\"#{fetch(:app_path)}/sites/default/settings.php\", \"drush/drush.yml\")\n\n# Link dirs files and private-files\nset :linked_dirs, fetch(:linked_dirs, []).push(\"#{fetch(:app_path)}/sites/default/files\")\n```\n\nThen, all the others information related to your Git repository or debug level\n\n```ruby\n# Default value for :scm is :git\nset :scm, :git\n\n# Default value for :log_level is :debug\nset :log_level, :debug\n```\n\nFinally, set the deployment to use the proper Drupal 8 strategy\n\n```ruby\nnamespace :deploy do\n  # Ensure everything is ready to deploy.\n  after \"deploy:check:directories\", \"drupal:db:backup:check\"\n\n  # Backup the database before starting a deployment and rollback on fail.\n  # after :updated, \"drupal:db:backup\"\n  # before :failed, \"drupal:db:rollback\"\n  # before :cleanup, \"drupal:db:backup:cleanup\"\n\n  # Set the maintenance Mode on your Drupal online project when deploying.\n  after :updated, \"drupal:maintenance:on\"\n\n  # Must updatedb before import configurations, E.g. when composer install new\n  # version of Drupal and need updatedb scheme before importing new config.\n  # This is executed without raise on error, because sometimes we need to do drush config-import before updatedb.\n  after :updated, \"drupal:updatedb:silence\"\n\n  # Remove the cache after the database update\n  after :updated, \"drupal:cache:clear\"\n  after :updated, \"drupal:config:import\"\n\n  # Update the database after configurations has been imported.\n  after :updated, \"drupal:updatedb\"\n\n  # Clear your Drupal 8 cache.\n  after :updated, \"drupal:cache:clear\"\n  \n  # Obfuscate Drupal sensitive files by removing or by denying access to them.\n  # after :updated, \"drupal:security:obscurity:files\"\n  # after :updated, \"drupal:security:obscurity:htaccess\"\n\n  # Disable the maintence on the Drupal project.\n  after :updated, \"drupal:maintenance:off\"\n\n  # Ensure permissions are properly set.\n  after :updated, \"drupal:permissions:recommended\"\n  after :updated, \"drupal:permissions:writable_shared\"\n\n  # Fix the release permissions (due to Drupal restrictive permissions)\n  # before deletting old release.\n  before :cleanup, \"drupal:permissions:cleanup\"\nend\n```\n\nYou may now can configure your `staging.rb` and `production.rb` strategy, has you will certainly deploy on different environment\n\n```shell\nvi config/deploy/staging.rb\n```\n\n```ruby\n# staging.example.org\nset :deploy_to, '/var/www/staging.example.org'\n\n# set a branch for this release\nset :branch, 'dev'\n\n# Map composer and drush commands\n# NOTE: If stage have different deploy_to\n# you have to copy those line for each \u003cstage_name\u003e.rb\n# See https://github.com/capistrano/composer/issues/22\nSSHKit.config.command_map[:composer] = -\u003e { shared_path.join('composer.phar') }\nSSHKit.config.command_map[:drush] = -\u003e { release_path.join('vendor/bin/drush') }\n```\n\n```shell\nvi config/deploy/production.rb\n```\n\n```ruby\n# www.example.org\nset :deploy_to, '/var/www/example.org'\n\n# set a branch for this release\nset :branch, 'master'\n\n# Map composer and drush commands\n# NOTE: If stage have different deploy_to\n# you have to copy those line for each \u003cstage_name\u003e.rb\n# See https://github.com/capistrano/composer/issues/22\nSSHKit.config.command_map[:composer] = -\u003e { shared_path.join('composer.phar') }\nSSHKit.config.command_map[:drush] = -\u003e { release_path.join('vendor/bin/drush') }\n```\n\nAwesome, your configuration is complete !\n\n## Usage\n\nSo, after configuration come action ! The first time, you have to run this command with the choosing stage.\n\n```shell\ncap [staging|production] deploy:setup\n```\n\nIn fact, Capistrano create directories and symlink to the targeted server. The `shared` directory contains all shared files of your app who don't need to be change. `Releases` contains the different releases of your app with a number define in `deploy.rb` and finally `current` is the symlink who target the right release.\n\n```\nexample.org\n├── current -\u003e /home/example.org/releases/20130527070530\n├── releases\n│   ├── 20130527065508\n│   ├── 20130527065907\n│   └── 20130527070530\n└── shared\n```\n\nNow, every time you want to deploy your app !\n\n```\ncap [staging|production] deploy\n```\n\nAnd if some troubles occur, just launch the rollback command to return to the previous release.\n\n```\ncap [staging|production] deploy:rollback\n```\n\nYou should then be able to proceed as you would usually, you may want to familiarise yourself with the truncated list of tasks, you can get a full list with:\n\n```\ncap -T\n```\n\n## Credits\n\nInspired by [capistrano-drupal](https://github.com/previousnext/capistrano-drupal).\n\nMade by [Antistatique](https://antistatique.net) who's always looking for new talented developers ! Just mail us on [job@antistatique.net](mailto:job@antistatique.net).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantistatique%2Fcapdrupal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantistatique%2Fcapdrupal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantistatique%2Fcapdrupal/lists"}