Categories
How To

AutoDeploy: Github to DreamObjects

There are a lot of things that Github makes easy. One of them is a great way to keep versions of data publicly accessible, trackable, and deployable.

Well. Not so much that last one.

Automated deployment with Github can be incredibly convoluted, twisted, and perplexing. If you don’t speak high geek, it’s worse. Thankfully there are services like Codeship that let you ship code, run tests, and more importantly, run some hefty commands.

When the day came that I wanted to keep some JSON files on Github for version control, but deploy them to the cloud, I knew what to do. I was already doing a version of the process, in reverse, for my Remoteless SVG images, after all.

Create Your Repository Create Your Repository

Now I’m using Github, but Codeship supports Bitbucket or Gitlab, so that’s also an option. Once you’ve made your repository, commit your code but don’t push anything yet! We have to make a couple decisions first.

First: Branches.

I have two philosophies of this. If I’m working on something like a plugin or a theme or an app that needs versioned releases, I’m going to name my branches REL_1.2.3 and so on. If, instead, I’m maintaining a theme or plugin for personal use, I have a development branch that I use for all normal dev work. I may spin up a special branch for some new feature, but it always goes into that dev branch first.

Second: Deployments.

The reason I use that branch system is that when I push to the dev branch, it pushes code to the dev server.

Schnieder from One Day at a Time (2017) going 'Mind blown'
Mind? Blown.

Once you decide how you want your set up to deploy, and when, you’re ready to Ship That Code.

Gettit? Right…

Top ↑

Setup Codeship Setup Codeship

If you’ve never setup Codeship before, I explain how you do that in my post about Deploying from Github with Codeship. The special sauce here is your Custom Script.

Before you write the script, add in Environment Variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY with those names specifically. This way you won’t have to write a mess of custom code.

pip install 
awscli aws s3 --endpoint-url https://objects-us-east-1.dream.io sync ~/clone/ s3://bucket-name/

The important bits:

  • Endpoint URL is my S3-esque host
  • bucket-name is my bucket name…

Top ↑

Push Your Code Push Your Code

Once that’s saved, you can push code and it’ll automatically kick the code to the cloud.

A lot of this is obviously a backwards implementation of code I already described, but sometimes we need something explained in the straightforward way to help us move forward.

Enjoy your deploys!