GitHub Actions

Weng Kee Teh
3 min readMay 30, 2022

I think CI/CD (Continuous Integration Continuous Delivery) is truly a Godsend at this time where cloud native is the norm. Layers and layers of abstractions, new technology from CNCF that requires you to spin up another operator, infrastructure and application code intertwined with each other… you get the idea. But developers are really blessed with abundance of choices in CI/CD, all thanks to the great contributions of the open source community.

Today, let’s talk about GitHub Actions.

If you’re using GitHub, GitHub Actions probably will be your main goto when it comes to CI/CD. And if you’re came across Azure DevOps before, you will find the way of writing GitHub Actions YAML file look very familiar, perhaps due to the fact that both belongs to Microsoft company. By creating an Actions file in the .github/workflows directory, a workflow would be created for you, and can viewed from the Actions tab of your GitHub repository.

Below is the Actions file snippet copied from the quick start guide by GitHub

name: GitHub Actions Demo
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."

Personally, I find it pretty easy to use. It is in YAML format and very readable. On the core, this Actions will run on Ubuntu and will be triggered on commit push, to echo a bunch of informations, checkout the source and list all the files in the repository. If you are familiar with Linux, this should be fairly easy to read.

And there is a pretty OK visualization on the steps in GitHub Actions tab of the repository. From the picture below, all the information that you need to know are there, e.g. name of the step, duration it takes to ran for each step, whether the step has succeed or failed and etc.

But this is pretty basic, don’t you think?

Don’t worry, GitHub Marketplace got you covered. There are tonnes of Actions written and contributed by the community, if you want to implement something in GitHub Actions, chances are someone already write one and uploaded it to the Marketplace. E.g. Docker build and push, build and package Java with Maven, unit test, etc.

Even if there is none, you can always write one yourself. But remember to contribute back to the Marketplace!

--

--

Weng Kee Teh

A builder, a gamer, an explorer. Disclaimer: the views expressed here are those of the author, and do not reflect the views of his employer