Getting Started with GitHub Actions- Part 1

Getting Started with GitHub Actions- Part 1

What are GitHub Actions?

GitHub Actions is a (CI/CD), where CI stands for continuous integration and CD stands for Continuous delivery. This allows you to automate your build, test, and deployment pipeline.

What are the components of GitHub Actions?

In GitHub actions, everything starts from an event such as a pull request push issues and events are tied with workflows and they are triggered when an event occurs in your GitHub repository. Each workflow has at least one job. If you want to know more about jobs so (check) and each job is associated with runners

Create your first GitHub Action

In this example, we are going to create a GitHub action for node.js. We will create a node.yml file and this YAML file defines a workflow named "Node.js GitHub Action" that triggers on push to the main branch and pull requests. It runs on an Ubuntu environment and consists of four steps: checking out the repository, setting up Node.js version 18, installing dependencies using npm ci,

Step 1 Create a .github/workflows directory in your repository on GitHub.

Step 2 In the .github/workflows directory, create a file named node.yml.

Step 3 You can follow the example code.

name: Node.js GitHub Action

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v3

    - name: Setup Node.js
      uses: actions/setup-node@v3
      with:
        node-version: '18'

    - name: Install dependencies
      run: npm ci

Did you find this article valuable?

Support Shivam Sharma by becoming a sponsor. Any amount is appreciated!