GitHub Action context and its Capabilities - Blogs

GitHub Action context and its Capabilities

About Context

Contexts basically helps to get the information about workflow runs, runner environments, jobs, and steps. Contexts, objects, and properties will vary importantly under different workflow run conditions. For example, the matrix context is only populated for a matrix job.

Now we will talk about valuable Context

GitHub Context

The GitHub context contains information about the workflow run and the event that triggered the run. GitHub context object contains all the properties. Now we'll look at a GitHub Context sample.


When we run this action context, it displays all of the information as shown in the screenshot below.


Runner Context

The runner context contains all the information about the runner that is executing the job. Below is the example.


Here's a screen shot of what the output would look like.


Every detail, such as the runner's name, operating system, and arch, will be displayed. The temporary directory and workspace for runners are also included.

When we Use Context

GitHub Actions contains a collection of variable called contexts and a similar collection of variables called default environment variable.

  • Default Environment Variable
  • Contexts

Default Environment Variable

You can use environment variables to store information that you want to reference in your workflow. The default environment variable in GitHub is available for every step in a workflow file. GitHub sets environment variable for actions to use in all runner environment. you can set your own custom environment variables or you can use default environment variables that GitHub sets automatically.

RUNNER_OS is a default environmental variable. For example the below workflow could be run successfully if you changed the operating system from macOS-latest to windows-latest .


If conditionals are handled by GitHub Actions, the two if statements in the above example examine the OS attributes of the runner context, and only steps where the check resolves as true are passed to the runner. Only one of these steps is delivered to the runner because one of the checks is always true and the other is always false. The process is completed once the job is sent to the runner.


Contexts can be used at any step in your workflow, even if the default environment variables aren't available. Now we'll look at how two different sorts of environment variables can be combined in a job.

Job 1:


Job 2:


These two jobs are defined in such a way that job 1 will only run if changes come from the Development branch, and job 2 will only run if changes come from the Main branch.


Kubernetes basic Objects

In this article, we will learn about the basic objects of Kubernetes in detail with their respective...

Read More >

Material Design in Android – Working with Toolbar

Introduction to Material DesignMaterial Design is a comprehensive guide for visual, motion and inter...

Read More >

GitHub Codespaces Features and Capabilities

Codespaces are a safe, configurable, and dedicated development environment that has all of the capab...

Read More >

3 Layered Architecture

IntroductionHere in this article, I would like to cover the typical three layer architecture in C# ....

Read More >

What is ingress and what are the components of it?

Ingress is a resource, which exposes the http and https from external sources to the services within...

Read More >

How to print TransHeader and TransFooter in Microsoft Dynamics NAV RDLC reports

We know that TransHeader and TransFooter section types were available in NAV 2009 version but there ...

Read More >

NAV – Connecting Microsoft Dynamics CRM customized entities

This blog is intended to see how Microsoft Dynamics NAV (here onwards NAV) can be connected to exter...

Read More >

VSTS Team project Monitor

Let us discuss how to install VSTS team project monitor and how we can make use of it easily.Particu...

Read More >

Create Restful service using Web API

What is Asp.Net Web API?Asp.Net Web API is a framework for building HTTP services that can be consum...

Read More >


Try DevOpSmartBoard Ultimate complete Azure DevOps End-to end reporting tool

Sign Up

  • Recent
  • Popular
  • Tag
Monthly Archive

Contact Us
  • *
  • *