카테고리 없음
Git : Action
SciomageLAB
2024. 10. 4. 12:03
반응형
CI 워크플로우 만들기
예시
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
on
: 트리거 종류runs-on
: 가상머신 환경matrix
: 종류(?). 여기에 버전이 3가지면 버전을 3개 모두에 대해서 워크플로우를 동작시킴
아래 예시의 경우 총 6가지 버전 조합에 대해 명령을 수행strategy: matrix: os: [ubuntu-lastest, windows-2016] node-version: [8.x, 10.x]
path
와uses: actions/upload-artifact@master
: 깃헙이 제공하는 스토리지 공간으로 최대 90일 동안path
에 아티팩트가 저장됨. 반대로 다운로드도 가능(download-artifact@master
)run
: 스크립트 명령. 쉘도 쓸 수 있고 node.js기반의 github 스크립트도 사용가능하다..github/scripts
밑에 여러 스크립트를 만들어 놓고 응용할 수 있다.
용어 설명 : Workflows, steps, actions, and jobs
조건문, 환경변수로 develop과 production 나눠 배포
env
: 사용자가 직접 정의한 환경변수name: CI on: push jobs: prod-check: if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - run: echo "$GUEST Deploying to production server on branch $GITHUB_REF" env: NAME: Guest
워크플로우 디버깅 하기
secret에ACTIONS_RUNNER_DEBUG
와ACTIONS_STEP_DEBUG
값을 true로 설정하면 워크플로우가 실패했을 때 좀더 자세한 로그를 볼 수 있다.참고문헌
GitHub Actions를 사용하여 CI(연속 통합) 워크플로 빌드
반응형