0Pricing
Node.js Backend Development Bootcamp · บทเรียน

ไปป์ไลน์ CI/CD ด้วย GitHub Actions

ทำให้การทดสอบและการนำแอป Node.js ไปใช้งานเป็นอัตโนมัติ ด้วยการสร้างไปป์ไลน์การผสานรวมและส่งมอบอย่างต่อเนื่องผ่าน GitHub Actions

ไปป์ไลน์ CI/CD ด้วย GitHub Actions เป็นบทเรียน Node.js Backend Development Bootcamp ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Node.js Backend Development Bootcamp และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Node.js Backend Development Bootcamp มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

What is CI/CD?

Continuous Integration (CI) automatically builds and tests your code on every push. Continuous Delivery/Deployment (CD) automatically ships passing code to production.

Together they catch bugs early and remove manual, error-prone release steps.

Why GitHub Actions?

GitHub Actions runs workflows directly in your repository. There is no separate server to manage, it integrates with pull requests, and it has a generous free tier for public repos.

Workflow File Location

Workflows are YAML files inside .github/workflows/. Each file describes one workflow, and a repo can have many.

// .github/workflows/ci.yml

Triggers

The on key defines what starts a workflow. Common triggers are pushes and pull requests to specific branches.

name: CI
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

Jobs and Runners

A workflow has one or more jobs. Each job runs on a fresh virtual machine (a runner) you select with runs-on.

jobs:
  test:
    runs-on: ubuntu-latest

Steps

A job is a sequence of steps. A step either runs a shell command (run) or uses a prebuilt action (uses).

    steps:
      - uses: actions/checkout@v4
      - run: echo 'Code checked out'

Setting Up Node.js

The official setup-node action installs the Node version you specify and can cache dependencies for faster runs.

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

Installing and Testing

With Node ready, install dependencies and run your test suite. If tests fail the job fails, blocking the merge.

      - run: npm ci
      - run: npm test

A Complete CI Workflow

Here is a full, minimal pipeline that checks out code, sets up Node, installs, and tests on every push and pull request.

name: CI
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 20, cache: npm }
      - run: npm ci
      - run: npm test

Secrets

Never commit API keys. Store them in your repo's Settings > Secrets and reference them with the secrets context. They are masked in logs.

      - run: ./deploy.sh
        env:
          API_KEY: ${{ secrets.API_KEY }}

Adding a Deploy Step

For CD, add a job that runs only after tests pass and only on the main branch, then deploys. The needs and if keys control ordering and conditions.

  deploy:
    needs: test
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - run: echo 'Deploying...'

Quick Check

Test your CI/CD knowledge.

Recap

You built an automated pipeline with GitHub Actions:

  • Workflows live in .github/workflows/ as YAML
  • on sets triggers; jobs run on runs-on runners
  • Steps use prebuilt actions or run shell commands
  • Install with npm ci and run npm test automatically
  • Store credentials in secrets and gate deploys with needs + if

Now every push is tested and safe code can ship automatically.

คำถามที่พบบ่อย

บทเรียน “ไปป์ไลน์ CI/CD ด้วย GitHub Actions” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “ไปป์ไลน์ CI/CD ด้วย GitHub Actions” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Node.js Backend Development Bootcamp ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Node.js Backend Development Bootcamp มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “ไปป์ไลน์ CI/CD ด้วย GitHub Actions”

ทำให้การทดสอบและการนำแอป Node.js ไปใช้งานเป็นอัตโนมัติ ด้วยการสร้างไปป์ไลน์การผสานรวมและส่งมอบอย่างต่อเนื่องผ่าน GitHub Actions คุณปฏิบัติ Node.js Backend Development Bootcamp ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Node.js Backend Development Bootcamp หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Node.js Backend Development Bootcamp บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “ไปป์ไลน์ CI/CD ด้วย GitHub Actions” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Node.js Backend Development Bootcamp นี้ได้ไหม

ได้ บทเรียน Node.js Backend Development Bootcamp ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. การจัดคอนเทนเนอร์ด้วย Docker
  2. การนำไปใช้งานบนคลาวด์ (AWS/Heroku)
  3. การจัดการกระบวนการด้วย PM2
  4. ไปป์ไลน์ CI/CD ด้วย GitHub Actions
← กลับไปที่ Node.js Backend Development Bootcamp