반응형

needs 

GitHub Actions에서 jobs 항목을 사용하여 여러 작업을 순차적로 실행시키려면, needs 키워드를 사용하면 된다.

이렇게 needs 키워드를 사용하면 다른 작업이 완료될 때까지 대기할 수 있다.

아래 예시에서는 jobs에 의해 build, test, deploy 작업이 순차적으로 실행된다.

 

test 작업은 build 작업이 완료되어야 하며, deploy 작업은 test 작업이 완료되어야 진행된다.

이렇게 의존성을 정의하면 작업을 병렬로 실행하면서도 작업 간에 순서를 지정할 수 있다.

 

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Build app
        run: |
          # build app

  test:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Run tests
        run: |
          # run tests

  deploy:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Deploy app
        run: |
          # deploy app
반응형