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

단계

~11 min · steps, run, uses

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

단계는 한 러너에서 순차적으로 실행돼

작업 안에서 단계들은 같은 러너에서 차례로 실행돼. 단계 사이에는 파일 시스템이 그대로 유지돼. 단계가 실패하면 작업도 실패해(continue-on-error가 없다면).

단계는 두 가지 유형이 있어:

  1. run: 단계 — 셸 명령을 실행해. 기본 셸은 Linux/macOS에서 bash, Windows에서 pwsh야.
  2. uses: 단계 — 재사용 가능한 액션을 호출해. 형식은 uses: org/repo@ref야.

자주 쓰는 단계 필드

  • name — 로그에 표시할 친근한 이름이야. 선택 사항이지만 붙여두면 좋아.
  • id — 내부 식별자야. 이후 단계에서 이 단계의 출력값을 참조할 때 써.
  • if — 표현식으로 단계 실행을 제어해.
  • env — 단계 범위의 환경 변수야.
  • working-directory — 단계가 시작할 디렉토리야.
  • shell — 기본 셸을 덮어써.
  • continue-on-error — 단계가 실패해도 작업은 실패하지 않아.
  • timeout-minutes — N분 뒤에 단계를 강제 종료해.
  • withuses: 액션의 입력값 맵이야.

Code

자주 쓰는 단계 형태들·yaml
steps:
  # uses: invoke an action
  - uses: actions/checkout@v4
    with:
      fetch-depth: 0

  # uses + with: pin runtime version
  - uses: actions/setup-python@v5
    with:
      python-version: '3.12'

  # run: shell command
  - name: Install
    run: |
      python -m pip install --upgrade pip
      pip install -r requirements.txt

  # run + id: capture output for later steps
  - name: Get short SHA
    id: sha
    run: echo "sha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT

  - name: Use captured output
    run: echo 'short SHA was ${{ steps.sha.outputs.sha }}'

External links

Exercise

단계 5개를 가진 작업을 짜봐: checkout, setup-node, install, lint, 테스트. 각 단계에 name:을 달아줘. 여섯 번째 단계는 github.event_name == 'pull_request'일 때만 실행되도록 추가해: echo 'this is a PR build'.

Progress

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

댓글 0

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

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