Skip to content

Instantly share code, notes, and snippets.

@brigleb
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save brigleb/51bab67e9d0c180732d7 to your computer and use it in GitHub Desktop.

Select an option

Save brigleb/51bab67e9d0c180732d7 to your computer and use it in GitHub Desktop.
How to deploy a special-purpose git branch with Grunt assets

Our goal is to have a special branch (one or more) matching a production environment. Using a service like Beanstalk, you want to be able to push to one of those branches, and have it end up at the server with compiled Sass, JavaScript, image, and other assets. You're unable to run your tools on the server, but you want to keep your repository free from these messy compiled assets.

Let's assume we're using a kind of Gitflow methodology, and that our branch for deployment will be called staging.

You have been doing your work on the develop branch... or wherever...

1. Check out your branch.

git checkout staging

2. Merge so that the branch we're merging from overrides everything on our staging branch.

git merge -s recursive theirs

3. Build the Gruntfile.

grunt build or equivalent

4. Add in compiled Grunt assets (despite .gitignore instructions)

git add -f ./css

5. Commit changes

git commit -am 'staging deployment'

Ideally, you're omitting the m option, and writing something much more helpful here.

6. Push changes

git push origin staging

7. Deploy

If your branch is not set up to auto-deploy via Beanstalk or whatever method, you now need to visit the website and initiate a deployment.

Alternately, we just deploy with a tool that does our sync for us. We're using Transmit now, which can mirror, but it could be done with a command line tool like lftp as well.

Then, our main concern is with tagging a release. We could really just think of a helpful command to make "release notes" for a tag, which would be added to its description, or something like that. Really, if we're tagging consistently, it could be a straightforward part of our workflow.

Resources to look into:

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