728x90
github action으로 CI를 할 수 있다.
push, pull request, 배포 할 때 주로 사용해 봤다.
이번에는 pull request를 생성할 때 validation 하는 workflow와 배포할 때 CI하는 workflow를 작성했다.
방법은 아래와 같다.
우선 root에 .github 폴더를 생성하고 그 아래 workflow 폴더를 생성한다.
생성한 폴더에 pullrequest.yml 파일을 생성한다.
name: pull request
on:
# 만약 master에 push 될 때도 작동시키고 싶으면 아래 주석한것을 사용하면 된다.
# push:
# branches:
# - master
pull_request:
branches:
- '*' # 모든 브랜치
jobs:
pull_request_validator: #job id
runs-on:
- ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Use Node.js 18.16.1
uses: actions/setup-node@v3
with:
node-version: 18.16.1 # 특정 node version을 지정 할 수 있다.
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build apps
run: npm run build
- name: Run linters
run: npm run lint
- name: Run unit test
run: npm test
on 구문에서 workflow가 작동되는 시점을 정의할 수 있다.
위의 예제처럼 action으로 지정 할 수 있고, cron job으로 스케줄을 걸 수도 있다.
schedule:
- cron: '30 5,17 * * *'
그 외에도 다양한 조건이 있는데 자세한 건 아래 문서 링크에서 확인해보면 된다.
https://docs.github.com/ko/actions/using-workflows/events-that-trigger-workflows#schedule
워크플로를 트리거하는 이벤트 - GitHub Docs
GitHub에 대한 특정 작업이 예약된 시간에 발생하거나 GitHub 외부의 이벤트가 발생할 때 실행되도록 워크플로를 구성할 수 있습니다.
docs.github.com
728x90
'내가 보려고 기록하는것' 카테고리의 다른 글
actions/checkout@v2 download fail (0) | 2023.09.06 |
---|---|
쿠버네티스 배포 전략 종류 (rolling update, recreate ...) (0) | 2023.08.15 |
chatGPT 쿼리 튜닝 꽤나 잘해준다. (0) | 2023.05.24 |
SSO, OAuth, SAML, OIDC (0) | 2023.04.27 |
VScode Auto fix eslint on save (0) | 2023.04.18 |