DEV Community

Cover image for Understanding GitHub Actions
Shaista Aman Khan
Shaista Aman Khan

Posted on

Understanding GitHub Actions

GitHub Actions is a powerful tool provided by GitHub that allows developers to automate workflows for their repositories. It enables automation of tasks such as testing, building, and deploying applications directly from the GitHub repository. In this comprehensive guide, we will explore the various components of GitHub Action.
Some useful links to study in depth about github actions:
Github Quick Start
Github Actions Marketplace
Guides for GitHub Actions

Components of GitHub Actions
1. Workflow
A workflow in GitHub Actions is a configurable automated process that comprises one or more jobs. It is defined using a YAML file named workflow.yml placed in the .github/workflows directory of your repository. Workflows can be triggered based on events like pushes, pull requests, or schedules.

2. Jobs
Jobs are a collection of steps that execute on the same runner. Workflows can contain multiple jobs that run in parallel or sequentially. Each job can define the environment, execution platform, and steps needed to complete the job's tasks.

3. Steps
Steps are individual tasks within a job. They represent the actions performed during the job execution. Each step can be a shell command, an action, or a reference to an external action defined by the community or the repository owner.

4. Actions
Actions are shareable and reusable units of code that can perform specific tasks. They encapsulate individual tasks, making it easier to reuse code across workflows. Actions can be created by the community or by the repository owner and can be used in workflows to perform tasks like building, testing, or deploying applications.

5. Runners
Runners execute jobs in a GitHub Actions workflow. GitHub provides hosted runners with various operating systems (Linux, macOS, Windows) and environments pre-installed. Alternatively, self-hosted runners can be used to customize the execution environment.

Here is how a GitHub action .yml file looks like:

name: Deploy Reactjs App

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2

      # Add steps to build and deploy the Reactjs application


Enter fullscreen mode Exit fullscreen mode

Now that we understand the fundamental components of GitHub Actions, in the next blog let's proceed with a step-by-step tutorial to deploy a Reactjs application in AWS S3 using GitHub Actions.

Top comments (0)