C.W.K.
Stream
Lesson 08 of 12 · published

Workflow YAML 해부

~13 min · yaml, syntax, anatomy

Level 0Apprentice
0 XP0/101 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

전체 top-level 모양

조각들은 다 봤어. Workflow 파일의 전체 top-level 모양, GitHub 가 기대하는 순서대로:

  • name — 표시 이름.
  • run-name — run 별 이름 (template 기반, 옵션).
  • on — event.
  • permissionsGITHUB_TOKEN 이 할 수 있는 것.
  • env — workflow level env var.
  • defaults — 기본 shell, working dir.
  • concurrency — cancel-in-progress group.
  • jobs — 실제 작업.

자주 놓치는 필드

  • permissions — 기본적으로 GITHUB_TOKEN 이 너무 관대. Workflow level 에 permissions: read-all 박고 job 별로 override 해서 least-privilege 강제.
  • concurrency — 없으면 모든 push 가 새 run 시작. 있으면 같은 branch / PR 의 in-progress run 취소 가능.
  • defaults.run.shell — script 에 bash-ism 필요하면 Linux/macOS 에서 bash 명시 (Mac 기본 sh 가 놀래킬 수 있어).

Code

Production 급 workflow header·yaml
name: ci
run-name: ci on ${{ github.actor }} / ${{ github.head_ref || github.ref_name }}

on:
  pull_request: {}
  push:
    branches: [main]
  merge_group: {}

permissions: read-all

env:
  PYTHON_VERSION: '3.12'
  NODE_VERSION: '22'

defaults:
  run:
    shell: bash

concurrency:
  group: ci-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    permissions:
      contents: read
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: echo "Python $PYTHON_VERSION, Node $NODE_VERSION"

External links

Exercise

기존 workflow 가져와 top level 에 세 가지 추가: permissions: read-all, concurrency: + cancel-in-progress, defaults.run.shell: bash. Push 하고 run 통과 확인.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.