Menu

1 / 2

GitHub Actions CI/CD Complete Guide

DEV Community: cicd·WDSEGA·5 months ago
#CdsyBBoU
#dev#actions#node#uses#article
Reading 0:00
15s threshold

Introduction

GitHub Actions is one of the most popular CI/CD tools today. This guide covers everything from basics to advanced techniques.

Basic Workflow Structure

name : CI/CD Pipeline

on : push : branches : [ main , develop ] pull_request : branches : [ main ]

jobs : test : runs-on : ubuntu-latest steps : - uses : actions/checkout@v4 - uses : actions/setup-node@v4 with : node-version : ' 18' - run : npm ci - run : npm test

Enter fullscreen mode

Exit fullscreen mode

Matrix Builds

Test across multiple environments:

strategy : matrix : node-version : [ 16 , 18 , 20 ] os : [ ubuntu-latest , windows-latest ]

Enter fullscreen mode

Exit fullscreen mode

Caching

Speed up builds with caching:

- uses : actions/setup-node@v4 with : node-version : ' 18' cache : ' npm'

- uses : actions/cache@v3 with : path : ~/.cache/pip key : ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}

Enter fullscreen mode

Exit fullscreen mode

Reusable Workflows

Create reusable workflow:

#…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.