Getting Started with GitHub Actions

Archit Sharma - Jan 27 - - Dev Community

GitHub Actions is a platform to automate, customize, and execute software development workflows

Prerequisites

Before we get started, these following prerequisites are recommended:

  • Basic understanding of GitHub (create repo, push/pull/commit, pull requests, etc.)
  • Basic knowledge of YAML

Core concepts of GitHub Actions

1. Workflow

A Workflow is an automated process that will run one or more jobs and will run when triggered by an event.
GitHub workflows are written in YAML. The workflow refers to the .yml file you will create in your repository. It is usually stored in your .github/workflows/ directory.

2. Event

Events are specific activities that trigger a workflow run. For example, a workflow triggered is when someone creates a pull request, opens an issue, or pushes a commit to a repository.

3. Runner

Runners are servers that runs your workflows when they're triggered. Ubuntu Linux, Microsoft Windows, and macOS are the runners provided by GitHub to run your workflows. It can be GitHub-hosted or self-hosted.

4. Jobs

A job is a set of steps in a workflow that is executed on the same runner. Each step is either a shell script that will be executed, or an Action that will be run. Steps are executed in order and are dependent on each other.

5. Actions

Actions are the smallest portable building block of a workflow and can be combined as steps to create a job. You can create your own Actions or use publicly shared Actions from the Marketplace.

Create a Workflow

  1. In your repository, create the .github/workflows/ directory to store your workflow files.

  2. In the .github/workflows/ directory, create a new file called blank.yml and add the following code.

name: blank
run-name: ${{ github.actor }} is learning GitHub Actions
on: [push]
jobs:
  check-bats-version:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v3
        with:
          node-version: '14'
      - run: npm install -g bats
      - run: bats -v

Enter fullscreen mode Exit fullscreen mode

NOTE: You don't have to understand the YAML code for now, we'll discuss it in upcoming posts.

3.Commit these changes and push them to your repository.

Congratulations! You have just installed a GitHub Actions workflow file in your repository, and it will run automatically each time someone pushes a change to the repository.

Thanks for reading! I hope it has given you a simple overview on how GitHub Actions work, what it does and how to get started with a simple workflow.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .