So I Wanted To Deploy A Binary

You Shall Not Pass!

Benjamin

--

The Story So Far

In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move… just kidding!

It all started quite recently. On Thursday evening, at 6:42pm to be slightly more precise. I had some bandwidth, and so decided to tackle a long-standing thorn in my team’s side — enabling manual deployment using our CircleCI environment.

Up until Thursday evening, we had had various ideas of using (see: building & maintaining) different tools, or utilising an entirely separate service, to achieve our end-goal.

Ideally, we should have been able to tap into the CircleCI API, and trigger jobs this way. Unfortunately, as of the time of writing, it is currently not possible to trigger a single job (via the API) if you are using CircleCI 2.1 and Workflows.

However, we had a simpler solution at hand, unbeknownst to us.

Workflows

According to CircleCI’s documentation, in order to increase the speed of software development through faster feedback, shorter reruns, and more efficient use of resources, we should configure Workflows.

We already used these, and they served us well.

But there was a config key which we weren’t aware of — type: approval. The documentation surrounding it was confusingly worded and difficult to understand. But after a few re-reads, I got there.

Approval

When you give a job under a CircleCI workflow the approval type, the “job” must be entirely unique within your config.yml. For example, if you have three main jobs defined:

  • build
  • test
  • deploy

Each of which run inside your workflow/s, then the manual trigger must be named something other than any of the above. It also must be defined only within your workflows. Furthermore, in order for the manual trigger to actually work, another subsequent job must depend upon it.

I named my trigger deploy-branch. This will only be run when one opens the CircleCI Web UI, and initiates it manually. In other words, when one gives approval.

Results

Once I went ahead and tweaked a workflow to include a job withtype: approval, we had a bona fide manual trigger available to us. It doesn't have a fancy interface, such as a Github label, or a Slackbot command, however it does exactly what it says on the tin.

Conclusion

As an iOS Developer by trade and specialty, I well and truly stepped outside my comfort zone while fiddling with our CI environment.

However, I feel that this little adventure helped me deepen my skillset overall, when it comes to the build environment enveloping the apps that I help create.

I can only hope that this helps other teams. If you already knew how to do this, then good for you! However I didn't, so I decided to blog about it. 😋

Thanks for reading!

If you liked this post, consider giving me a clap, or seven. このストーリーを好きだったら、拍手して下さいませんか?

--

--