C.W.K.
Stream
Lesson 04 of 14 · published

Composite action

~12 min · composite, action, reusable

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

Job 안의 재사용 step

Composite action 은 여러 step 을 단일 uses:-able 단위로 묶는 YAML 파일. Reusable workflow 가 자기 runner 에서 도는 전체 job 이라면, composite action 은 호출 job 의 runner 에서 인라인으로 도는 step 시퀀스.

언제 어느 거

  • Reusable workflow전체 job 원할 때 (별도 runner, 병렬, 자기 permission). '표준 test suite 돌리기' 나 '표준 deploy' 에 최선.
  • Composite action — 기존 job 안의 반복 가능한 step 시퀀스 원할 때. '이상한 Python env 세팅' 이나 'Docker image build & tag' 에 최선.

해부

Composite action 은 .github/actions/<name>/action.yml (로컬) 이나 자기 repo (공유) 에 살아. 파일에 runs.using: composite 와 step 리스트 선언.

Code

Composite action — 로컬·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
Caller — composite 사용·yaml
      - uses: ./.github/actions/setup-pippa-env
        with: { python-version: '3.12' }
      - run: pytest -q

External links

Exercise

Workflow 의 두 job 에 반복되는 5+ step 시퀀스 찾기. .github/actions/ 아래 composite action 으로 추출. 두 job 다 한 uses: + 실제로 다른 step 만 남음.

Progress

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

댓글 0

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

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