Some time went by since Actions was announced at last year's GitHub Universe, the platform's annual conference that attracts a (very) large developer audience. Actions is promoted as the new way to automate and customize your workflows.
Configuring the apps and services that make up your CI/CD pipeline takes time and effort. GitHub Actions instead offers up several components for you to connect and automate your workflow. In fact, a common response to the announcement was that people hoped to use Actions to write their own (CI/CD), or that GitHub would offer a plug-and-play solution.
The holy grail of pipeline orchestration
Pre-launch GitHub invited several companies and individuals to test the Actions feature. Like Jessie Frazelle. In her (past) role as Developer Advocate at Microsoft Azure, and former maintainer of Docker, Jessie used Actions to fix her "complicated and excessively orchestrated" open source workflow. Actions allows her to work with all of the containers she needs, and coordinate her release process, whilst mainting a high-level overview through its GUI.
Actions can be written in any language using the millions of Open Source libraries available on GitHub, and can interact with the full GitHub API and any other public API.
Ultimately Actions will enable us mere mortals to build, package, release, update, and deploy our project in any language, without having to lift a key stroke. I say ultimately, because GitHub didn't detail the when and the how of a public launch. But you can join the waiting list here.
We were able to look over the shoulder of a friendly GitHub employee, and play around with the new tooling while access to Actions is still very much restricted.
Not quite intuitive, yet
Common sense dictates to first familiarize yourself with the documentation, before tinkering with any new technology. Needless to say we decided instead to just try and fail fast.
The visual editor is intuitive up to the point where you'd need to create custom actions. If a component (or action, I guess) doesn't exist, you're free to add your own. Without visual prompts guiding you, it's fairly easy to make changes to the wrong input field. Our workflow kept failing because we mistakenly changed 'label' and not 'uses'.
Drag the blue connector down to create your first action.
We figured that when using the featured actions, it would always use the default settings specified in the action's source's Dockerfile, unless we'd overwrite those settings directly in the action element.
What do we want? Automated gem builds!
One of the actions featured in the version that's currently exclusively available to GitHub employees and a selected and undisclosed group of Beta testers, is the 'GitHub Action for npm', which wraps the npm CLI to enable common npm commands.
We set out to instead make an example workflow to build and publish a Ruby library (or: gem) to the default public registry, and created a GitHub repository, with a Docker container for a 'Rubygems' action: https://github.com/scarhand/actions-ruby
Building a gem builder
The facetor repository on GitHub. Private, as for now Actions is only available for private repositories.
So first we ‘configure’ an action, by pointing it to its relative path - Niels already created a repo with all our Actions code living in it - for our ‘Build the Gem’ Action for RubyGems to use it. We will repeat the steps for our push component.
Next, we connect to rubygems.org, because ultimately we want to publish our gem to their hosting service. After logging into your RubyGems account, go to ‘edit your profile’ to gather your API access auth token.
Back in the Actions interface, you’ll want to create a new secret (underneath the GITHUB_TOKEN checkbox) for your RUBYGEMS_AUTH_TOKEN. With the second step of our main.workflow
completed we commit the new file to the master branch.
Pushing with a release tag (vx.x.x following common semantic versioning) reveals a candidate for release in ‘Releases’ in our repository. Don’t forget the actual step of ‘drafting’ your new release.
Although our first try wasn’t the immediate success we hoped for, the process of releasing is enormously satisfying to monitor in the Actions GUI.
v.0.2.0 of our simple hello world gem is now up on rubygems.org, bringing jack all to your application. Really, try it, run gem install factor
and see it do absolutely nothing, except demonstrating how you can use GitHub actions to trigger gem releases automatically.
We look forward to hear about your experiments, provided you've also been granted early access to this all-together promising feature!
Pro tip: Try act for debugging your GitHub Actions locally. It's far better than the manual docker build/run we initially used.