본문 바로가기
C.W.K.
Stream
Lesson 08 of 12 · published

워크플로 YAML 해부

~13 min · yaml, syntax, anatomy

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

최상위 구조 전체

지금까지 조각들을 모두 살펴봤어. 이제 워크플로 파일의 최상위 구조를 GitHub가 기대하는 순서대로 정리해 보자.

  • name — 표시 이름.
  • run-name — 실행마다 부여되는 이름(템플릿 기반, 선택 사항).
  • on — 이벤트.
  • permissionsGITHUB_TOKEN이 할 수 있는 일.
  • env — 워크플로 수준 환경 변수.
  • defaults — 기본 셸과 작업 디렉터리.
  • concurrency — 진행 중인 실행을 취소하는 그룹.
  • jobs — 실제 작업.

자주 놓치는 필드

  • permissions — 기본적으로 GITHUB_TOKEN 권한이 너무 관대해. 워크플로 수준에서 permissions: read-all을 지정하고 작업마다 덮어써서 최소 권한을 강제하자.
  • concurrency — 이게 없으면 모든 푸시마다 새 실행이 시작돼. 있으면 같은 브랜치나 PR에서 진행 중인 실행을 취소할 수 있어.
  • defaults.run.shell — 스크립트에 bash 문법이 필요하면 Linux나 macOS에서 bash를 명시해(Mac 기본 sh가 까다로울 수 있어).

Code

프로덕션급 워크플로 헤더·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

기존 워크플로를 가져와서 최상위에 세 가지를 추가해: permissions: read-all, concurrency:와 진행 중인 실행 취소, 그리고 defaults.run.shell: bash. 푸시하고 실행이 통과하는지 확인해.

Progress

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

댓글 0

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

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