GitHub Action context and its Capabilities - Blogs
X
05May

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.

Photos1

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

Photos2

Runner Context

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

Photos3

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

Photos4

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 .

Photos5

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

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:

Photos6

Job 2:

Photos7

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.

Related

How to upload documents to SharePoint 2013

IntroductionSharePoint is a browser-based collaboration, content management, and extensible platform...

Read More >

How to Create a Provisioning profile for iOS

To Run an app on iOS device,you must have a Provisioning Profile installed on your device. ...

Read More >

Key Metrics to Measure DevOps Success

DevOps words means many things to many people and all the definitions might be partly right. DevOps ...

Read More >

Openbravo Services

We are happy to announce our newly acquired partnership with Openbravo, Spain. Openbravo is the prov...

Read More >

Identifying Web Elements using Selenium Webdriver

What is Web Element?             &n...

Read More >

Azure App Service (Build And Host Web Apps, Mobile-Back Ends Without Managing Infrastructure)

In this blog we will see what is Azure App Service, and it’s  features and why do we use it, we can...

Read More >

3 Layered Architecture

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

Read More >

Introduction to Load Testing

 Well, before learning what is Load testing. Let us discuss briefly the performance testing.&nb...

Read More >

Database deployment using GitHub Actions

In this blog, I will be showing how to export the database file from SQL Server and import the same ...

Read More >

Microsoft Dynamics NAV Control & recognizes add-ins

NAV fill in assembly list table with these 3 fields and when NAV looks for dll it uses these fields ...

Read More >

Share

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

Sign Up

  • Recent
  • Popular
  • Tag
Monthly Archive
Subscribe
Name

Text/HTML
Contact Us
  • *
  • *