Github Actions is the new kid around the block for workflow automation. DevOps guys are having the day for it, as it makes a heck of a lot easier for them to implement CI/CD ๐ฅ from the same place they host their project.
Last month, I worked on setting up a workflow for building a deployment pipeline. The project that Iโm part of, is a desktop application ๐ฅ built on Electron.
You might be thinking ๐ค, why build a desktop app on Githubโs Actions? Because the build process is quite cumbersome and take a pretty big chunk of the developers precious time ๐. As we were already planning to build a CI/CD pipeline, we thought to give it a try with Github Actions ๐ (as we already host our project on Github privately).
Disclaimer: This post applies to Githubโs Linux and Windows runners, as I have tested on those. Although Mac OS runner isnโt much different then the Linux runner. You can find more about them HERE.
Testing the workflow locally
When I'm trying out something new ๐ฑโ๐, the first thing I try is to set up a local environment to test it out ๐งโโ๏ธ. Can it be done for Github Actions? The answer is not definitive ๐ค. We can use our own Docker Image as a custom runner, and test it locally on that local Docker Image. We canโt create the exact environment to mock the workflow, at least I couldnโt find any solution.
Complex processes
Setting up a YAML configuration for projects that already use some kind of framework, or has a rich set of build tools is really easy โ. But when we are writing configuration for an application where the build ๐ญ requires multiple process, with sources from different languages and frameworks, it kinda becomes messy to keep track of the process flow. Sure you can divide the processes into โJobsโ but that has its own pitfall ๐, which Iโll talk about later in this post.
Actions from Marketplace
On the Github Marketplace, there are quite a lot of actions written by other developers ๐ฉโ๐ป. These actions can be written in two ways, using Docker configuration or using JavaScript. While JavaScript actions run on all platforms, actions written in Docker configuration can only run on Linux. So, we might find some action that cuts down your task into half, but still canโt use it, only because we are using Non-Linux runner.
Data persistence on a workflow
In a complex build ๐ญ process, you may want to pass some information from one job to another, to build a flow. The only way to pass data in-between jobs, is to use Github Artifacts. They arenโt cheap either. You canโt delete an artifact manually ๐ฒ. GitHub stores artifacts for 90 days for pushes and pull requests. Storing artifacts uses storage space on GitHub. Also, for private repositories like ours, there is a fixed amount of โFree Minutesโ and โStorageโ after which it will start billing ๐ต. One good thing is that files uploaded as artifacts are compressed as โzipโ. So, if you are uploading log files or reports, you may not need to think about the storage, at least ๐.
Limited flexibility for Actions
One particular problem I faced ๐คจ while using an action from marketplace is that, we canโt set working-directory
when executing them. That means, those actions must always be executed from the root directory ๐ฌ. This wonโt matter if we are building a single project. But if itโs a monorepo, then the actions wonโt work if it doesnโt accept the directory path as parameter. In my case, the action accepted a directory path, so I was saved somehow ๐.
Thatโs it for today folks. See you, when I see you ๐ฑโ๐ค.
Cover Image Credit: kaleidico
Top comments (2)
I've had some quite good results with Github Actions. Then again I'm not doing anything crazy complicated at the moment anyway.
I'm not aware of any way of realistically testing a build process. Have you done something in the past that would be worth sharing? As you say though with Container based CI you can wrap the container and test the internal logic.
The project that I talked about, is proprietary, that's why I couldn't share any of the code. Thing that I did in the past were very simple, so I don't think they will be worth your time.
What I meant by test is that, Github has detailed documentation on their system specification and environment of the runners. So, we could recreate the same setup on a Docker for testing. Alternatively, we could run create a custom Docker image and write the build process with Gulp/Grunt or some other libraries. But I haven't tried it myself.