GitHub Actions: Now CI/CD baked-in
Earlier this year, GitHub Actions was released which is a platform for developer workflow orchestration and automation. While Actions already has been popular, a recent announcement might mean a game-changer for CI/CD landscape. The announcement says that GitHub Actions will be supporting CI/CD - right from your source code repository! In this article, I share my experience of using GitHub Actions in beta.
Let's start with the cool features:
- Any OS/Language/Platform: You can build, test, and deploy your projects on any platform, including Linux, macOS, Windows, in a container or in a virtual machine. Actions also supports Node.js, Python, Java, PHP, Ruby, C/C++, .NET, Android, and iOS. For the demo provided, I'm using Node.js/Ubuntu combination.
- Multi-container testing: You can test your web service and its database together by simply adding some docker-compose to your workflow file. I haven't tried out this feature but it is a powerful option for real projects where you'd need to simultaneously test multiple containers.
- Matrix builds: This feature allows you to test multiple versions of your project, in parallel. Check-out the following code-snippet which runs tests on multiple versions of node as well as OS (Code source: here):
jobs: test: name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: node_version: [8, 10, 12] os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v1 - name: Use Node.js ${{ matrix.node_version }} uses: actions/setup-node@v1 with: version: ${{ matrix.node_version }} - name: npm install, build and test run: | npm install npm run build --if-present npm test
- Live logs: Live logs provide rich feedback into the progress of your builds as they run. GitHub streams your logs to the Actions console to show your status in real time. A sample run of my CI build process with live logs is shown near the end of this article.
Enough theory! Let's try it out by creating a CI build process which will build the image from your source code and push it to an image registry (need beta access if you're trying before Nov13). Step-by-step instructions are provided on my GitHub repo (a sample run shown in the image below). Don't worry if you do not have beta access to GitHub Actions; its GA-ing on Nov.13 and will be free for public repositories.
Very insightful