Github Actions
Github Actions
ํน์ ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ์ ๋ ์ํ๋ ์์ ์ ์๋์ผ๋ก ์ํํ๊ฒ ๋ง๋ค์ด์ฃผ๋ ๋๊ตฌ
ํ๋ก์ ํธ ๋ฃจํธ ๊ฒฝ๋ก์
.github/workflows/
๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํ๊ณ.yml
ํ์ผ์ ๋ง๋ค์ด ์ํฌํ๋ก์ฐ๋ฅผ ์ ์ํ๋ค.
// workflows ์ด๋ฆ
name: CI
// workflows๋ฅผ ์คํ์ํฌ ํธ๋ฆฌ๊ฑฐ
// ๊ฐ ์ด๋ฒคํธ ํ์์ ์ง์ ํ๋ ์์ธ ์ค์ ์ AND ์ฐ์ฐ์๋ฅผ ์ฌ์ฉํ์ฌ ์กฐ๊ฑด์ด ์ถฉ์กฑ๋์ด์ผ ์คํ๋จ
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
// job์ ์คํ์ํฌ ํ๊ฒฝ์ ์ง์
runs-on: ubuntu-latest
steps:
// uses๋ ์ด๋ฏธ ๋ง๋ค์ด๋ Action์ ์ฌ์ฉํ๊ฒ ๋ค๋ ๊ฒ
// checkout์ 'runs-on'์ ๋ช
์ํ ์ํฌํ๋ก์ฐ ์คํ ํ๊ฒฝ์์ ํด๋น ํ๋ก์ ํธ๋ฅผ ๋ถ๋ฌ์ค๋ ๋์์ ์๋ฏธ
// ์ํฌํ๋ก์ฐ์ ์ฒซ ๋ฒ์งธ ๋จ๊ณ์์ ์ฌ์ฉ๋๋ฉฐ ๊ผญ ํ์ํ๋ค.
- name: Checkout
uses: actions/checkout@v3
// node.js ํ๊ฒฝ ์ธํ
- name: Set up Node.js
uses: actions/setup-node@v3
// with์ ์ฌ์ฉํ์ฌ ์ก์
์ ๊ฐ ์ ๋ฌ
with:
node-version: '16'
// ์ข
์์ฑ์ ๊ด๋ฆฌํ๊ณ ์บ์ฑํ ํจํค์ง๋งค๋์ ์ง์
cache: npm
// ์ข
์์ฑ ์ค์น
- name: Install dependencies
// run์ package.json์ ์ ์ํ ์คํฌ๋ฆฝํธ ๋ช
๋ น์ด๋ฅผ ์คํ์ํค๊ธฐ ์ํด ์ฌ์ฉ๋จ
run: npm ci
- name: Lint
run: npx eslint --ext .js,.jsx,.ts,.tsx .
- name: Compile to check syntax
run: npx tsc --noEmit
- name: Run tests
run: npx jest --verbose --coverage
- name: Build
run: npm run build
- name: Run E2E test
run: HEADLESS=true npm run ci
Events
When - ์ํํ ์์ ์ด ํธ๋ฆฌ๊ฑฐ๋๋ ์ํฉ
github์์ ๋ฐ์๋๋ ๋๋ถ๋ถ์ ์ด๋ฒคํธ๋ฅผ ์ง์ ํ ์ ์๋ค.
ex) push, merge, pr ์์ฑ ๋ฑ
์ด๋ฒคํธ๊ฐ ํธ์ถ๋๋ฉด ์ํฌํ๋ก์ฐ๊ฐ ์คํ๋๋ค.
Workflow
ํน์ ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ์ ๋ ์คํ๋๋ ์์ ๋ค์ ์งํฉ
ํ๋์
workflows
๋ ํ๋ ๋๋ ๋ค์์job
์ ๊ฐ๋๋ค.
Job
์ํฌํ๋ก์ฐ ๋ด์์ ์คํ๋๋ ๋ ๋ฆฝ์ ์ธ ์์
๊ธฐ๋ณธ์ ์ผ๋ก ๋ณ๋ ฌ๋ก ์คํ๋๋ค.
job
์ ํ๋ ์ด์์step
์ผ๋ก ๊ตฌ์ฑ๋๋ค.shell script
๋๋npm ๋ช ๋ น์ด
์์ฑ ๊ฐ๋ฅ
Actions
ํน์ ์์ , ๋ช ๋ น์ด๋ฅผ ์คํํ๋ ๋จ์
์์ฃผ ์ํ๋๋ ์์ ์ ์ก์ ์ผ๋ก ์ ์ํ์ฌ ์ฌ์ฌ์ฉ์ฑ์ ๋ํ๋ค.
Github actions ์๋ ์ฌ์ ์ ์ ์๋ ๋ค์ํ ์ก์ ๋ค์ ์ ๊ณตํ๋ค.
Composite Action
์ฌ๋ฌ ๊ฐ์ ๋จ์ผ ์ก์ ์ผ๋ก ๊ตฌ์ฑ๋์ด ๋ ๋ณต์กํ ์์ ์ ์ํํ๊ธฐ ์ํด ์ฌ์ฉ๋๋ค.
Composite Action์ ์ํฌํ๋ก์ฐ์ ๋ ๋ฆฝ์ ์ผ๋ก ๊ด๋ฆฌํ๊ธฐ ์ํด ๋ณ๋์ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํ์ฌ ๊ด๋ฆฌํ์.
Composit Action๋ง๋ค ๊ฐ๋ณ ํด๋๋ฅผ ๋ง๋ค๊ณ
action.yml
ํ์ผ์ ์์ฑํ์ฌ ์ ์ํ๋ค.using: 'composite'
๋ก ์ ์ธํด์ผ ํ๋ค.ํด๋น ์ก์ ์ ์ฌ์ฉํ๋ ๊ณณ์์
uses
๋ฅผ ํตํด ์ก์ ์ ์๋ ๊ฒฝ๋ก๋ฅผ ์ง์ ํ์ฌ ์ฌ์ฉํ๋ค.uses: ./.github/actions/yarn-install
Runner
์์ ์ ์ํํ ์คํ ํ๊ฒฝ์ผ๋ก github์์ ํธ์คํ ํ์ฌ ์ํฌํ๋ก์ฐ๋ฅผ ์คํ์ํค๊ธฐ ์ํด ์ฌ์ฉ๋๋ค.
job
์ ์คํํ๋ ๊ฒ์ด ๋ฐ๋กRunner
,job
์ ๋ ๋ฆฝ์ ์ธRunner Container
์์ ์คํ๋๋ค.
Last updated