Intro to GitHub Actions

Shivaganesh
3 min readApr 14, 2023

--

GitHub is very popular git repository hosting platform. It has many features to ease the collaboration. Today we will go through one such feature namely GitHub Actions.

GitHub Actions is a Continuous Integration and Continuous Delivery platform in GitHub. It allows to build, test and deploy the applications contained in the repository. Thus, we need not configure separate CICD pipeline using other tools.

Let us now start with the basics.

1. GitHub Project

Here, I have created a sample github repository named github-actions-tutorial. I have added HelloFromJava.java which returns “Hello, Github Actions working!” when executed.

Now to enable GitHub actions, we can either check Actions section to use any workflows available else we can also configure our own workflows. For that we need to add a YAML configuration file in .github/workflows folder.

Here is the content of a yml file added in the repository.

name: Build java

on: push

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Compile
run: javac HelloFromJava.java

- name: Run java
run: java HelloFromJava

This is a simple workflow configuration which has steps to compile and execute a java application.

name — This is the name of the workflow

on — It signifies when to run this workflow. In this case, whenever there is a push to the repo, trigger the workflow.

jobs — It contains all the jobs of the workflow. here we have only on job i.e., build.

runs-on — where the job needs to run

steps — job steps.

actions/checkout@3 — It checksout the repository into the $GITHUB_WORKSPACE so the workflow will be able to access it.

actions/setup-java@3 — It helps to setup java environment with required version and distribution.

There are further steps to compile and execute the java file.

Now to see how this GitHub Actions workflow works, just push a commit. Then after a while, a green/red tick mark appear as highlighted in the first image. If it is green tick, it means workflow executed successfully, else it is a failure. You can check the Actions section and it looks like below in case of success.

2. Job Build Detail

In the above screenshot, we can see all the job steps are available and we can further check what has happened in each step which allows us to debug if any issues.

This is just a basic GitHub Actions workflow. We can do a lot. There are several GitHub Actions configurations available in Actions section and we can also build custom complex workflows.

Having said that, GitHub Actions is free for Standard GiHub hosted runners in public repositories and self hosted runners. In other cases, billing is applicable. Please find more details here.

Thats all folks in this blog. We will see several other interesting topics in future. Thank you for reading this and I hope you have learnt something useful.

--

--

Shivaganesh
Shivaganesh

Written by Shivaganesh

Blockchain Developer experienced in developing Supply chain, Pharma, Telecom domain solutions using Hyperledger Fabric, R3 Corda, Symbiont Assembly and DAML

No responses yet