GitHub Workflows For Test Automation

What are GitHub Actions?

GitHub Actions are event driven. It allows us to automate tasks within the software development lifecycle. For example, let’s say if any teammate creates a PR (pull request) on repo, we can automatically run a command that executes a software testing script with the help of GitHub Actions.

Since GitHub marketplace has plenty of actions which are already created by other parties, an extra effort is not needed to get going.

Components of GitHub Actions

GitHub Actions mainly includes the following components.

  • Workflows
  • Events
  • Jobs
  • Steps
  • Actions
  • Runners

A very important aspect of GitHub Action is the .yml file(this is a human-readable data-serialization language which supports all programing languages).


In this blog, I am going to test some of the REST APIs and invoke these APIs through the Postman tool (CLI tool: Newman) and run some tests based on the results returned. 

Even though this blog explains only about the process of running tests, this process can be incorporated as part of Continuous Integration (CI), and then in each of the release pipelines for Continuous Deployment (CD) or a step prior to release in Continuous Delivery (CD).

Setting up GitHub Actions

  1. Adding an ACTION
  2. You need to create a folder named .github/workflows/ in the root directory of your repo to store workflows.

  3. Workflow File

    The below lines of code define the name of the workflow and that it will run when a push event occurs on the master/main branch of the repo.

    • 2.1 Now create the job which will run the Postman collection

    • 2.2 Installing Node and Newman (including newman-reporter--htmlextra)

      Postman can be run inside CI/CD agents using the CLI Tool called Newman. Before installing Newman we need to install node.js first since Newman is built on node.js as shown below.

    • 2.3 Directory for test results

      Then we need to create a directory and upload the results to it. The directory can be created using the following steps.

    • 2.4 Running the Postman collection

      Our next task is to execute the tests defined in the Postman collection. The Postman collection file (.json) is available in the repository as shown below. 

    • As shown below, it executes the Postman collection via Newman and generates the html report for the test run using newman-reporter--htmlextra.

    • 2.5 Uploading artifacts

      For the last step we need to upload the artifacts to the workspace. 

  4. Testing
  5. We can push some code to the master/main repository to check how the workflow is triggered.

    The entire workflow file (.yml) is as below:

    Note: Please refer the GitHub repo for more info link

    Email notifications & configuration

    By default, a notification is sent to the owner of the repository to inform them of the failed build. But we can change this by unchecking “Send notifications for failed workflows only”.


Automation is one of the best ways to increase productivity in a software project and GitHub Actions provides an easy way to improve the quality of our code and make life more productive.



Nirmala Katupothage

Associate QA Lead