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

Job 의존 — needs:

~11 min · needs, dag, ordering

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

needs: 가 그리는 DAG

각 job 은 needs: 로 0 개 이상의 upstream job 선언. GitHub 가 이걸로 DAG 만들고 위상 순서로 job 실행. 사이 경로 없는 job 들은 병렬.

흔한 모양:

  • 선형 — A → B → C. 각각 이전 거 대기.
  • Fan-out, fan-in — A → [B, C, D] → E. B/C/D 가 A 다음 병렬, 그 다음 E 가 셋 다 대기.
  • 다이아몬드 — A → [B, C] → D. build-then-(test, lint)-then-deploy 에 흔함.
  • 분리된 체인 — 같은 workflow 에 사는 독립 pipeline.

실패 전파

기본적으로 needs: 중 하나가 실패하거나 취소되면 그 job 은 skip. 정리 / 알림 job 이 어쨌든 돌아야 하면 if: always()if: failure() 로 override.

Code

always-run notify 가진 diamond DAG·yaml
jobs:
  build:
    runs-on: ubuntu-latest
    steps: [{ uses: actions/checkout@v4 }, { run: ./build.sh }]

  test:
    needs: build
    runs-on: ubuntu-latest
    steps: [{ uses: actions/checkout@v4 }, { run: ./test.sh }]

  lint:
    needs: build
    runs-on: ubuntu-latest
    steps: [{ uses: actions/checkout@v4 }, { run: ./lint.sh }]

  deploy:
    needs: [test, lint]
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps: [{ uses: actions/checkout@v4 }, { run: ./deploy.sh }]

  notify:
    needs: [test, lint, deploy]
    if: always()       # runs even if upstream failed/skipped
    runs-on: ubuntu-latest
    steps:
      - run: ./notify-slack.sh "${{ needs.deploy.result }}"

External links

Exercise

직렬 step 가진 workflow 가져와 diamond DAG 로 리팩토링: build → (test, lint) → deploy. Wall-clock 개선 시간 재고 PR 설명에 문서화.

Progress

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

댓글 0

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

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