Ind.ie is now Small Technology Foundation.
Commit dce71a32 authored by Aral Balkan's avatar Aral Balkan

Deployments are now Rsync-based. Removed Pulse.

parent 73c0e290
......@@ -12,3 +12,5 @@ npm-debug.log
**.mp4
**.ogv
**.webm
ssh-user
ssh-public-key-path
......@@ -748,9 +748,22 @@ writeFileAsync = (event, filePath, oldFolder, newFolder, oldExtension, newExtens
#
# Deployment
#
# Simply rsyncs the build/ folder to the public/ folder.
# 1. Rsyncs the build folder to the public folder.
# 2. Makes deployment-time string replacements in the public folder.
# 3. Rsyncs the public folder to static.ind.ie via ssh.
#
# Unless you are using your default SSH identity and/or if your
# username differs between your development machine and the
# deployment machine, you can create two configuration files:
#
# ssh-user: holds your username on the development machine e.g.,
#
# laura
#
# ssh-public-key-path: holds the path to your public key. e.g.,
#
# ~/.ssh/id_rsa2
#
# (The public folder is synchronised to the server via Pulse.)
#
######################################################################
......@@ -763,66 +776,49 @@ deploy = ->
deployAsync()
.then (message) ->
.then ->
#
# Replace necessary strings.
#
makeDeploymentStringReplacements(). then ->
message += 'Made deployment string replacements.\n\n'
return message
.then (message) ->
#
# Git commit the release so that we can
# roll back at any time.
#
execAsync('cd public && git status && cd ..').then (output) ->
reply = output[0]
if (reply.indexOf 'nothing to commit') > 0
#
# Nothing to commit; nothing to deploy
#
throw('No new changes to deploy.')
else
#
# Deploy the changes
#
execAsync('cd public && git stash && git pull && git stash pop && cd ..').then (output) ->
# log '>> ' + output
# message += 'Made deployment string replacements.\n\n'
return
.then ->
#
# Handle deployment time
# Deploy to server via rsync.
#
deploymentTime = moment().format() # ISO 8601
lastDeploymentTimeFile = 'public/.deployment-time'
fs.ensureFileAsync(lastDeploymentTimeFile).then ->
fs.readFileAsync(lastDeploymentTimeFile, 'utf-8').then (lastDeploymentTime) ->
# log 'Last deployment time: ' + lastDeploymentTime
fs.writeFileAsync(lastDeploymentTimeFile, deploymentTime).then ->
getLogEntriesSinceLastDeploymentCommand = 'git log --since "' + lastDeploymentTime + '" -10'
# Read the shell command from the ssh config file.
fs.readFileAsync path.join process.cwd(), 'ssh-user'
.then (sshUser) ->
fs.readFileAsync path.join process.cwd(), 'ssh-public-key-path'
.then (sshPublicKeyPath) ->
# log '>> ' + getLogEntriesSinceLastDeploymentCommand
user = if (sshUser.length == 0) then '' else "#{sshUser}@"
sshPublicKeyPath = if (sshPublicKeyPath.length == 0) then '' else " -i #{sshPublicKeyPath}"
execAsync(getLogEntriesSinceLastDeploymentCommand, {env: process.env}).then (summaryOfCommits) ->
changeToPublicFolderCommand = 'cd public'
gitAddCommand = 'git add --all'
gitCommitCommand = 'git commit -am "Version ' + deploymentTime + '\n\nIncludes following commits: \n\n' + summaryOfCommits + '"'
gitPushCommand = 'git push origin master'
changeBackToSourceFolderCommand = 'cd ..'
rsync = new Rsync()
.shell("ssh" + sshPublicKeyPath)
.flags('a', 'v', 'z', 'perms', 'chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r')
.exclude(['.*/'])
.source(process.cwd() + '/public/')
.destination("#{user}static.ind.ie:/var/www/")
.flags('delete')
# .dry()
fullGitCommand = changeToPublicFolderCommand + ' && ' + gitAddCommand + ' && ' + gitCommitCommand + ' && ' + gitPushCommand + ' && ' + changeBackToSourceFolderCommand
# log rsync.command()
execAsync(fullGitCommand).then (result) ->
message += 'Git: \n\n' + result
return message
.catch Promise.OperationalError, (e) ->
log 'Operational error: ' + e.message
.then (message) ->
log message + '\n' + (chalk.green.inverse 'Site deployed.' ) + '\n'
return new Promise ((fulfill, reject) ->
rsync.execute (error, code, cmd) =>
if error
errorMessage = (chalk.red.inverse 'Error in rsync: ') + code + '. ' + cmd
reject errorMessage
else
# Rsync complete.
fulfill()
)
.then ->
log '\n' + (chalk.green.inverse 'Site deployed.' ) + '\n\nhttps://ind.ie\n'
.catch Promise.OperationalError, (e) =>
log 'Operational error: ' + e.message
.catch ((e) ->
......@@ -838,7 +834,7 @@ deployAsync = ->
.flags('delete')
# .dry()
log rsync.command()
# log rsync.command()
return new Promise ((fulfill, reject) ->
rsync.execute (error, code, cmd) =>
......@@ -846,8 +842,8 @@ deployAsync = ->
errorMessage = (chalk.red.inverse 'Error in rsync: ') + code + '. ' + cmd
reject errorMessage
else
successMessage = 'Rsync complete:\n\nLocal copy:\nhttp://localhost:8001/\n\nRemote copy:\nhttps://ind.ie\n\nSync status:\n https://localhost:8080\n\n'
fulfill successMessage
# console.log 'Rsync build to public folder complete.s'
fulfill()
)
######################################################################
......
./pulse > /dev/null &
builder/bin/boot
\ No newline at end of file
......@@ -10,6 +10,7 @@ echo 'Remember to update aws-key.json with your actual keys if you want to deplo
git clone git@source.ind.ie:project/node-kit-0-8-0.git node_modules/node-kit
git clone git@source.ind.ie:project/indie-style-core.git source/assets/stylus/indie-style-core
git clone git@source.ind.ie:project/responsive-pixels.git source/assets/stylus/indie-style-core/responsive-pixels/
git clone git@source.ind.ie:project/static-ind-ie-public.git public
touch ssh-user
touch ssh-public-key-path
echo 'Done. Project installed for development.'
echo './dev to start the dev server.'
\ No newline at end of file
File deleted
indie-style-core @ bc427115
Subproject commit d87dd2b7d284b26526c340c07f5b287737f1db66
Subproject commit bc42711527d9c4ab0cd405563edccc8c9962449b
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment