Skip to content

Instantly share code, notes, and snippets.

@croxton
Last active June 6, 2019 17:44
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save croxton/38a27e06528ddfcdc131cee8ad2968b9 to your computer and use it in GitHub Desktop.
Save croxton/38a27e06528ddfcdc131cee8ad2968b9 to your computer and use it in GitHub Desktop.
Buddy Works Craft 3 post-deployment atomic deployment action

atomic-deploy-pipeline

if [ -d "releases/${execution.to_revision.revision}" ] && [ "${execution.refresh}" = "true" ]; then echo "Removing: releases/${execution.to_revision.revision}" && rm -rf releases/${execution.to_revision.revision}; fi
if [ ! -d "releases/${execution.to_revision.revision}" ]; then echo "Creating: releases/${execution.to_revision.revision}" && cp -dR deploy-cache releases/${execution.to_revision.revision}; fi
echo "Creating: persistence directories"
mkdir -p storage/craft
mkdir -p storage/cpresources
mkdir -p storage/uploads
echo "Symlinking: persistence directories"
ln -nfs ~/path/to/app/storage/craft ~/path/to/app/releases/${execution.to_revision.revision}/storage
ln -nfs ~/path/to/app/storage/cpresources ~/path/to/app/releases/${execution.to_revision.revision}/web/cpresources
ln -nfs ~/apps/clydecocampaigns/storage/uploads ~/apps/clydecocampaigns/releases/${execution.to_revision.revision}/web/uploads
echo "Linking current to revision: ${execution.to_revision.revision}"
rm -f current
ln -s releases/${execution.to_revision.revision} current
echo "Removing old releases"
cd releases && ls -t | tail -n +4 | xargs rm -rf
@croxton
Copy link
Author

croxton commented Feb 8, 2018

Note that persistent directories should either not be in your git repo at all, or you should specifically exclude them in the action that uploads files to your target server from the pipeline filesystem. If you have previously deployed them, you'll need to tick the checkbox to clear the cache before running the pipeline.

@davidhellmann
Copy link

What do you do here?
ln -nfs ~/path/to/app/storage/craft ~/path/to/app/releases/${execution.to_revision.revision}/storage whats inside the craft folder?
We talk about craft3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment