Blog Hoch
Jul 2026·2 tup leghDe'wI' chenmoHta'

GitHub Action wa'DIch ghItlh

#ci-cd#github#devops

Teams law' GitHub Actions workflow copy-paste (pIm repo) 'ej "Dun" Qoy. 'ach jaj Qapbe' 'e' yajchoH poQ: nuq run trigger, job 'ej step nuq, data chay' nob. naDev real workflow pagh vo' mach - pull request Hoch tests, tagged release Daq package publish.

workflow anatomy

workflow YAML file .github/workflows/ Daq. wej Dochmey: triggers (on) qaSDI' Qu', jobs steps ghom (VM wa' Daq), steps commands pagh actions job Daq.

name: CI

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

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

actions/checkout@v4 repo runner Daq clone - pagh vaj runner empty VM. actions/setup-node Node version install. npm ci (npm install pagh) CI Daq qatlh: package-lock.json exact install, lockfile pIm vaj fail.

matrix jobs parallel

Node versions pagh operating systems law' test vaj matrix wa' job definition law' parallel runs:

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [18, 20, 22]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm ci
      - run: npm test

wej independent jobs, Node version wa'-wa', parallel. ${{ matrix.node-version }} GitHub Actions expression syntax ghaH.

dependencies cache

job Hoch fresh VM Daq qaS, npm ci packages Hoch download (cache pagh):

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

setup-node cache option npm, yarn, pnpm Qu'. cache lockfile hash Daq jan. dependencies choHbe' vaj cache hit.

steps law' data nob

job wa' steps filesystem rap 'ach variables rap pagh. value step pIm nob vaj special output file ghItlh:

steps:
  - id: get_version
    run: echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"

  - run: echo "Building version ${{ steps.get_version.outputs.version }}"

id: get_version step pong nob - steps.get_version.outputs.version. pattern: laD, $GITHUB_OUTPUT ghItlh, downstream reference.

Secrets

credentials workflow file Daq hardcode Qo' - repo Daq commit, read access Hoch legh. repo Settings → Secrets and variables → Actions Daq store, secrets context reference:

- name: Publish package
  run: npm publish
  env:
    NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Secrets logs Daq mask automatic - step print vaj GitHub *** choH.

tagged releases neH

on.push.tags conditional job rap: version tag push vaj publish, tests Hoch push Daq:

name: Release

on:
  push:
    tags:
      - 'v*'

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          registry-url: 'https://registry.npmjs.org'
          cache: 'npm'
      - run: npm ci
      - run: npm test
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

v1.2.0 tag push vaj workflow Qu'. main commit Qu'be' - trigger tags Daq, branches pagh.

if: conditions

trigger neH Dun pagh. if: step pagh job gate:

- name: Notify on failure
  if: failure()
  run: echo "Build failed on ${{ github.ref }}"

failure() built-in function (success(), always(), cancelled() rap) previous steps outcome legh - notification Qagh neH.

workflow debug

cha' Dochmey poH Dun:

  • act - GitHub Actions workflows local Docker Daq Qu'. typo Hoch commit push pagh.
  • workflow_dispatch trigger - on: workflow_dispatch chel vaj "Run workflow" button GitHub UI Daq, push chu' pagh:
on:
  workflow_dispatch:
  push:
    branches: [main]

yaj

GitHub Actions workflow YAML neH (triggers, jobs, steps), ephemeral VMs Daq Qu' (actions/checkout neH). on:, jobs:, steps:, ${{ }} laD vaj workflow magic pagh, config file choH laH.

chu'Database Connection Pooling yajqanJavaScript Event Loop yaj