grunt-drupal-tasks
grunt-drupal-tasks copied to clipboard
Add support for deployment tooling
When writing the package task, the intent was to support a swappable deployment mechanism. Our two base cases being a fairly straightforward Capistrano rsync method and a pantheon/acquia friendly docroot commit to ops repo.
Nationally, these would be driven from grunt-shell tasks.
Also worth considering ShipIt
ShipIt maintainer is focused on very git-centric deployments. We do not want to do that for the mechanisms we most commonly use capistrano to achieve. There are other grunt-deploy plugins, but they mostly need a bit more flexibility and a rollback capability. Short term I am going to use the grunt package command in conjunction with a project-specific Capistrano 2 script.
We have some internal projects that have added some support for pushes to Pantheon, that would work well as a starting point for a release-repository model needed by Pantheon & Acquia. @fmitchell has more info on that.
I have a pantheon repo beside the drupal tasks repo.
I have specific tasks that clean profiles/ and sites/all, mkdir and copy, then a shell command that commits to the separate pantheon repo. The commit message is the tag. This is deployed using Jenkins.
In my Gruntconfig.json, something like:
"buildPaths": {
"build": "build",
"html": "build/html",
"temp": "build/temp",
"package": "build/packages",
"reports": "build/reports",
"profile": "src/profiles",
"custom_theme": "src/themes",
"modules": "build/html/sites/all/modules",
"themes": "build/html/sites/all/themes",
"libraries": "build/html/sites/all/libraries",
"pantheon": "../pantheon/repository",
"pantheon_profiles": "../pantheon/repository/profiles",
"pantheon_modules": "../pantheon/repository/sites/all/modules",
"pantheon_libraries": "../pantheon/repository/sites/all/libraries",
"pantheon_themes": "../pantheon/repository/sites/all/themes"
},
In my Gruntfile.js, something like:
shell: {
pantheon_clean: {
command: [
'cd <%= config.buildPaths.pantheon %>',
'rm -Rf sites/all/',
'rm -Rf profiles/'
].join('&&')
},
pantheon: {
command: [
'cd <%= config.buildPaths.pantheon %>',
'git add -A *',
'git commit -m "<%= grunt.option("message") %>"',
'git push origin master'
].join('&&')
}
},
copy: {
pantheon: {
files: [
{
expand: true,
cwd: '<%= config.buildPaths.profile %>/',
src: ['**', '!.gitkeep'],
dest: '<%= config.buildPaths.pantheon_profiles %>'
},
{
expand: true,
cwd: '<%= config.buildPaths.themes %>/',
src: ['**', '!.gitkeep'],
dest: '<%= config.buildPaths.pantheon_themes %>'
},
{
expand: true,
cwd: '<%= config.buildPaths.modules %>/',
src: ['**', '!.gitkeep'],
dest: '<%= config.buildPaths.pantheon_modules %>'
},
{
expand: true,
cwd: '<%= config.buildPaths.libraries %>/',
src: ['**', '!.gitkeep'],
dest: '<%= config.buildPaths.pantheon_libraries %>'
}
]
}
A separate release repository makes lots of sense, with possible value in a grunt plugin like https://www.npmjs.com/package/grunt-git-deploy. That would allow us to have some unification across Acquia, Pantheon, and other hosting environments.
However, we don't want that to be the only means GDT can support deployment, though it would be easy enough for a separate project to implement some other mechanism and override anything we might do with different behavior.
@grayside: could you explain more how you do it? I kind of put that content on files, but grunt don't put any think in that dir. I'm old php wolf, node and grunt still new territory for me.
I'm deploying to platform.sh, that is a lot like pantheon. I made a recipe with sh while we found a solution in js.
- Made a new directory build/platform
- Started a git repoctory there
- Use this platform_deploy.sh in proyect root:
#!/bin/bash
# clean last run
rm -r build/platform/*
rm -r build/platform/.htaccess
rm -r build/platform/.DS_Store
# create package
grunt package
# use package.tgz
tar zxf build/packages/package.tgz -C build/platform docroot
mv build/platform/docroot/* build/platform
mv build/platform/docroot/.[!.]* build/platform
rm -r build/platform/docroot
# git
cd build/platform
git add *
git commit -m "auto commit"
git push origin master
Hope its help somebody else!