codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
📦

Git & GitHub

29 / 63 topics
29Introduction to GitHub Actions30Creating and Managing Workflows31Using Secrets in GitHub Actions32Using Dependabot for Dependency Management33Code Review Best Practices on GitHub34Collaborating with Others on GitHub
Tutorials/Git & GitHub/GitHub Actions Basics
📦Git & GitHub

GitHub Actions Basics

Updated 2026-05-15
10 min read

GitHub Actions Basics

Introduction

GitHub Actions is a powerful automation tool that allows you to automate, customize, and execute your software development workflows right in your repository. With GitHub Actions, you can build, test, deploy, release, or trigger any job you need to keep your project moving forward.

In this tutorial, we will cover the basics of GitHub Actions, including how to create and configure workflows, understand events that trigger actions, and explore some common use cases.

Concept

GitHub Actions work by defining a series of steps in a workflow file. These files are written in YAML and are stored in your repository under the .github/workflows directory. A workflow is made up of one or more jobs, and each job consists of multiple steps.

Key Components

  1. Workflows: The main configuration file that defines the automation process.
  2. Jobs: A set of steps that execute on a runner machine.
  3. Steps: Individual tasks that can run commands, use actions, or run scripts.
  4. Events: Triggers for workflows to start running.

Workflow File Structure

A basic workflow YAML file might look like this:

name: CI

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Run a one-line script
      run: echo Hello, world!

Events

Workflows can be triggered by various events such as:

  • push: Triggered when code is pushed to the repository.
  • pull_request: Triggered when a pull request is opened or updated.
  • schedule: Triggered at specified times using cron syntax.

Examples

Let's walk through some practical examples to understand how GitHub Actions can be used in different scenarios.

Example 1: Running Tests on Code Push

Suppose you want to run tests every time code is pushed to the main branch. Here’s how you can set up a workflow for that:

name: Test Workflow

on:
  push:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Node.js
      uses: actions/setup-node@v2
      with:
        node-version: '14'
    - name: Install dependencies
      run: npm install
    - name: Run tests
      run: npm test

Example 2: Deploying to a Server

If you want to automate the deployment of your application to a server, you can use GitHub Actions to handle that:

name: Deployment Workflow

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up SSH key
      run: |
        mkdir -p ~/.ssh
        echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
        chmod 600 ~/.ssh/id_rsa
        ssh-keyscan -t rsa your-server.com >> ~/.ssh/known_hosts
    - name: Deploy application
      run: |
        scp -r . user@your-server.com:/path/to/deploy

Example 3: Automating Releases

You can automate the creation of releases when a new tag is pushed:

name: Release Workflow

on:
  push:
    tags:
      - 'v*.*.*'

jobs:
  release:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: ${{ github.ref }}
        release_name: Release ${{ github.ref }}
        body: |
          Changes in this Release

What's Next?

Now that you have a basic understanding of GitHub Actions, you can explore more advanced features and integrations. In the next section, we will cover "GitLab CI/CD Basics," where we will learn how to automate workflows using GitLab’s continuous integration and delivery tools.

By mastering GitHub Actions and other automation tools, you can streamline your development process, reduce manual errors, and improve collaboration within your team.


PreviousPublishing with GitHub PagesNext Creating and Managing Workflows

Recommended Gear

Publishing with GitHub PagesCreating and Managing Workflows