GitHub Actions: Creating a Simple Workflow

Ritika Singh
DSC KIET
Published in
3 min readApr 27, 2021

What Are Github Actions?

GitHub Actions are packaged scripts to automate tasks in a software development workflow in GitHub.

That is all the processes (or GitHub Events) like the creation of a pull request, committing your code, pushing into the production/ any branch, etc can be monitored by GitHub actions, and hence when an event occurs the workflow is triggered.

Github Actions Workflow

A GitHub Actions Workflow is a process that you set up in your repository to automate software development life cycle tasks. It is a configurable automated process made up of one or more jobs.

where to find Github Actions
Each repository has this actions tab in which the defined actions run

One must create a YAML file to define the workflow configuration. If you’re new to YAML and want to learn more, see Learn YAML in Y minutes.

GitHub actions are categorized as Container actions and JavaScript actions.

Container actions

As the name suggests in container actions, the environment is part of the action’s code. These actions can only be executed in Linux-based runners that GitHub hosts. Or if one wants to create a Self -hosted runner (read about runners) make sure it uses Linux OS and has Docker installed. Container actions support many different languages for execution.

JavaScript actions

They do not include the environment in the code. This means that one has to specify the environment to execute these actions. They can run in a VM in the cloud or on-premises. They not only support Linux but macOS and Windows environments also.

Let’s Start by Creating A Simple Workflow:

  1. Create a new repository and then create a workflow (say action.yml) in the workflows folder so the final path of your workflow will be like .github/workflows/action.yml
  2. Now, our first job is to add the on and name attribute to our workflow.

name: defines the name of your workflow.

on: defines the event on which the workflow has to be triggered.

There are plenty of Github events that trigger any workflow (read about GitHub events that trigger workflows)

Defining our First Workflow

3. Next essential requirement of a workflow is the job that it has to do (a workflow has to have a minimum of one job!)

4. One can define multiple jobs for a workflow. Each job has sundry attributes the major are name, runs-on, steps.

name: defines the name of that particular job in a workflow.

runs-on: defines the runner of that job. (runner can be a Github Hosted Runner or a self-hosted Runner)

steps: defines the steps to be taken in that job.

Creating multiple jobs for our workflow

5 . Commit the code, open the Actions tab in your repository and see your actions running!

So here you can see that all your jobs in the action.yml file ran successfully. And our job named custom3 (line 38) ran and gave us a DateTime output!

And Done! Aren’t GitHub Actions cool 😎!

Let me know in the comments if you have any doubts or face issues, hope it helps you. 😀

You can also reach out to me on LinkedIn and Twitter.

--

--