본문 바로가기
C.W.K.
Stream
Lesson 04 of 14 · published

컴포지트 액션

~12 min · composite, action, reusable

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

작업 안에서 재사용하는 단계

컴포지트 액션은 여러 단계를 하나의 uses:로 불러 쓸 수 있는 단위로 묶은 YAML 파일이야. 재사용 가능한 워크플로가 자기 러너에서 실행되는 전체 작업이라면, 컴포지트 액션은 이 작업을 호출한 러너에서 인라인으로 실행되는 단계들의 나열이지.

언제 무엇을 쓸까

  • 재사용 가능한 워크플로전체 작업이 필요할 때 써 (별도 러너, 병렬 실행, 자체 권한). '표준 테스트 스위트 실행'이나 '표준 배포'에 딱이야.
  • 컴포지트 액션 — 기존 작업 안에서 반복되는 단계 시퀀스가 필요할 때 써. '복잡한 파이썬 환경 세팅'이나 '도커 이미지 빌드 및 태그 지정'에 딱이야.

구조

컴포지트 액션은 .github/actions/<name>/action.yml (로컬)이나 자기 저장소(공유)에 둬. 파일 안에 runs.using: composite과 단계 목록을 선언하면 돼.

Code

컴포지트 액션 — 로컬·yaml
# .github/actions/setup-pippa-env/action.yml
name: 'Setup Pippa env'
description: 'Install Python 3.12 + uv + project deps'
inputs:
  python-version:
    description: 'Python version'
    required: false
    default: '3.12'
outputs:
  cache-hit:
    description: 'Whether deps were restored from cache'
    value: ${{ steps.uv.outputs.cache-hit }}
runs:
  using: composite
  steps:
    - uses: astral-sh/setup-uv@v3
      id: uv
      with:
        version: '0.5.x'
        enable-cache: true
    - run: uv python install ${{ inputs.python-version }}
      shell: bash
    - run: uv sync --all-extras --dev
      shell: bash
호출자 — 컴포지트 액션 사용·yaml
      - uses: ./.github/actions/setup-pippa-env
        with: { python-version: '3.12' }
      - run: pytest -q

External links

Exercise

워크플로의 두 작업에서 반복되는 5개 이상의 단계 시퀀스를 찾아봐. .github/actions/ 아래 컴포지트 액션으로 추출해. 그러면 두 작업 모두 하나의 uses:와 실제로 다른 단계만 남게 될 거야.

Progress

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

댓글 0

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

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