CICD

CICD

지속적 톡합(μ½”λ“œ λ³€κ²½ -> λΉŒλ“œ -> ν…ŒμŠ€νŠΈ -> μ½”λ“œ 병합) -> 지속적 제곡(μžλ™ 릴리슀) -> 지속적 배포(μžλ™ 배포)

지속적 톡합(Continuous Integration)

  • μ½”λ“œ 변경사항을 곡톡 브랜치둜 λ³‘ν•©ν•˜κΈ° 용이 ν•˜λ„λ‘ μžλ™ν™”ν•˜λŠ” 단계

  • μ½”λ“œμ˜ λ³€κ²½ λ‚΄μš©μ΄ λ°œμƒ -> μžλ™μœΌλ‘œ λΉŒλ“œ 및 ν…ŒμŠ€νŠΈλ₯Ό 트리거 -> μ™„λ£Œμ‹œ μ½”λ“œ 톡

  • "merge day"κ°€ ν•„μš” μ—†μ–΄μ§μœΌλ‘œ 인해 병합을 μœ„ν•œ μ‹œκ°„ μ ˆμ•½

지속적 제곡(Continuous Delivery)

  • CIλ₯Ό 거친 μ½”λ“œλ₯Ό μžλ™μœΌλ‘œ 리포지토리에 릴리슀(μ—…λ‘œλ“œ)ν•˜λŠ” 단계

  • 이 ν”„λ‘œμ„ΈμŠ€κ°€ λλ‚˜λ©΄ μ‹ μ†ν•˜κ²Œ ν”„λ‘œλ•μ…˜λ°°ν¬ν•  μ€€λΉ„κ°€ μ™„λ£Œ

지속적 배포(Continious Deployment)

  • 지속적 μ œκ³΅μ—μ„œ ν•œ 단계 더 λ‚˜μ•„κ°€ μ½”λ“œ λ³€κ²½ 사항 λ°œμƒ μ‹œ ν”„λ‘œλ•μ…˜ λ°°ν¬κΉŒμ§€ μžλ™μœΌλ‘œ μˆ˜ν–‰

  • 더 λΉ λ₯Έ μ†Œν”„νŠΈμ›¨μ–΄ μΆœμ‹œ 및 ν”Όλ“œλ°± 반영

Github Actions

Github ActionsλŠ” Github의 Repositoryμ—μ„œ λΉŒλ“œ, ν…ŒμŠ€νŠΈ 및 배포 νŒŒμ΄ν”„λΌμΈμ„ μžλ™ν™”ν•  수 μžˆλŠ” CI/CD ν”Œλž«νΌ

μ›Œν¬ν”Œλ‘œμš° μŠ€νƒ€ν„°: https://github.com/actions/starter-workflows

νƒ€μž…μŠ€ν¬λ¦½νŠΈ Actions: https://github.com/actions/typescript-action

ꡬ성 μš”μ†Œ

μ›Œν¬ν”Œλ‘œ(workflows)

YAML을 μ‚¬μš©ν•˜μ—¬ μ •μ˜λ˜κ³ , ν•˜λ‚˜ μ΄μƒμ˜ μž‘μ—…μœΌλ‘œ κ΅¬μ„±λœ ꡬ성 κ°€λŠ₯ν•œ μžλ™ν™” ν”„λ‘œμ„ΈμŠ€

μ›Œν¬ν”Œλ‘œλŠ” 순차적으둜 λ˜λŠ” λ³‘λ ¬μ μœΌλ‘œ 싀행될 수 μžˆλ‹€.

각 μž‘μ—…μ€ 가상 λ¨Έμ‹  λ˜λŠ” μ»¨ν…Œμ΄λ„ˆ λ‚΄λΆ€μ—μ„œ μ‹€ν–‰λœλ‹€.

YAML

[!NOTE]

μ›Œν¬ ν”Œλ‘œ νŒŒμΌμ€ λ¦¬ν¬μ§€ν† λ¦¬μ˜ .github/workflows 디렉터리 내에 .yml, .yaml파일둜 μ €μž₯λ˜μ–΄μ•Ό ν•œλ‹€

μ„œλ‘œ λ‹€λ₯Έ μž‘μ—…μ„ μœ„ν•œ μ—¬λŸ¬ 개의 μ›Œν¬ν”Œλ‘œ 파일이 μ‘΄μž¬ν•  수 μžˆλ‹€(λΉŒλ“œ μ›Œν¬ν”Œλ‘œ, ν…ŒμŠ€νŠΈ μ›Œν¬ν”Œλ‘œ, 배포 μ›Œν¬ν”Œλ‘œ λ“±)

이벀트(events)

μ›Œν¬ν”Œλ‘œλ₯Ό μ‹€ν–‰ν•˜λ„λ‘ νŠΈλ¦¬κ±°ν•˜λŠ” νŠΉμ • ν™œλ™. 리포지토리 λ‚΄μ˜ ν™œλ™, REST APIλ₯Ό ν†΅ν•œ ν™œλ™μ΄κ±°λ‚˜ cron을 ν†΅ν•œ 일정 μ˜ˆμ•½ 등을 ν•  수 μžˆλ‹€

이벀트이벀트 μ„€λͺ…

branch_protection_rule

λΆ„κΈ° 보호 κ·œμΉ™μ΄ 변경될 λ•Œ

check_run

검사 μ‹€ν–‰κ³Ό κ΄€λ ¨λœ μž‘μ—…μ΄ λ°œμƒλ  λ•Œ

check_suite

검사 도ꡬ λͺ¨μŒ μž‘μ—…μ΄ λ°œμƒν• 

create

Git μ°Έμ‘°(Git λΆ„κΈ° λ˜λŠ” νƒœκ·Έ)λ₯Ό λ§Œλ“€ λ•Œ

delete

Git μ°Έμ‘°(Git λΆ„κΈ° λ˜λŠ” νƒœκ·Έ)λ₯Ό μ‚­μ œν•  λ•Œ

deployment

배포λ₯Ό λ§Œλ“€ λ•Œ

deployment_status

νƒ€μ‚¬μ—μ„œ 배포 μƒνƒœλ₯Ό μ œκ³΅ν•  λ•Œ

discussion

토둠이 λ§Œλ“€μ–΄μ§€κ±°λ‚˜ μˆ˜μ •λ  λ•Œ

discussion_comment

ν† λ‘ μ˜ λŒ“κΈ€μ΄ λ§Œλ“€μ–΄μ§€κ±°λ‚˜ μˆ˜μ •λ  λ•Œ

fork

리포지토리λ₯Ό 포크할 λ•Œ

gollum

Wiki νŽ˜μ΄μ§€λ₯Ό λ§Œλ“€κ±°λ‚˜ μ—…λ°μ΄νŠΈν•  λ•Œ

issue_comment

문제 λ˜λŠ” λŒμ–΄μ˜€κΈ° μš”μ²­ μ„€λͺ…이 생성, νŽΈμ§‘ λ˜λŠ” μ‚­μ œλ  λ•Œ

issues

λ¬Έμ œκ°€ λ§Œλ“€μ–΄μ§€κ±°λ‚˜ μˆ˜μ •λ  λ•Œ

label

λ ˆμ΄λΈ”μ΄ λ§Œλ“€μ–΄μ§€κ±°λ‚˜ μˆ˜μ •λ  λ•Œ

merge_group

λŒμ–΄μ˜€κΈ° μš”μ²­μ΄ 병합 큐에 좔가될 λ•Œ

milestone

λ§ˆμΌμŠ€ν†€μ΄ λ§Œλ“€μ–΄μ§€κ±°λ‚˜ μˆ˜μ •λ  λ•Œ

page_build

GitHub Pages의 κ²Œμ‹œ 원본인 λΆ„κΈ°λ‘œ ν‘Έμ‹œν•  λ•Œ

project

ν”„λ‘œμ νŠΈ(ν΄λž˜μ‹)을(λ₯Ό) μƒμ„±ν•˜κ±°λ‚˜ μˆ˜μ •ν•  λ•Œ

project_card

ν”„λ‘œμ νŠΈ(ν΄λž˜μ‹)μ—μ„œ μΉ΄λ“œλ₯Ό μƒμ„±ν•˜κ±°λ‚˜ μˆ˜μ •ν•  λ•Œ

project_column

ν”„λ‘œμ νŠΈ(ν΄λž˜μ‹)μ—μ„œ 열을 μƒμ„±ν•˜κ±°λ‚˜ μˆ˜μ •ν•  λ•Œ

public

곡개 μƒνƒœκ°€ ν”„λΌμ΄λΉ—μ—μ„œ νΌλΈ”λ¦­μœΌλ‘œ 변경될 λ•Œ

pull_request

λŒμ–΄μ˜€κΈ° μš”μ²­μ— λŒ€ν•œ μž‘μ—…μ΄ λ°œμƒν•  λ•Œ

pull_request_comment(issue_comment μ‚¬μš©)

(λŒμ–΄μ˜€κΈ° μš”μ²­μ˜ diffκ°€ μ•„λ‹Œ) λŒμ–΄μ˜€κΈ° μš”μ²­μ— λŒ€ν•œ 주석이 생성, νŽΈμ§‘ λ˜λŠ” μ‚­μ œλ  λ•Œ

pull_request_review

λŒμ–΄μ˜€κΈ° μš”μ²­ κ²€ν† κ°€ μ œμΆœλ˜κ±°λ‚˜ νŽΈμ§‘λ˜κ±°λ‚˜ ν•΄μ œλ  λ•Œ

pull_request_review_comment

λŒμ–΄μ˜€κΈ° μš”μ²­ κ²€ν†  주석이 μˆ˜μ •λ  λ•Œ

pull_request_target

λŒμ–΄μ˜€κΈ° μš”μ²­μ— λŒ€ν•œ μž‘μ—…μ΄ λ°œμƒν•  λ•Œ

push

컀밋 λ˜λŠ” νƒœκ·Έλ₯Ό ν‘Έμ‹œν•˜κ±°λ‚˜ ν…œν”Œλ¦Ώμ—μ„œ 리포지토리λ₯Ό λ§Œλ“€ λ•Œ

registry_package

λ¦¬ν¬μ§€ν† λ¦¬μ—μ„œ GitHub Packages에 κ΄€λ ¨λœ μž‘μ—…μ΄ λ°œμƒν•  λ•Œ

release

릴리슀 μž‘μ—…μ΄ λ°œμƒν•  λ•Œ

repository_dispatch

GitHub μ™ΈλΆ€μ—μ„œ λ°œμƒν•˜λŠ” μž‘μ—…μ— λŒ€ν•œ μ›Œν¬ν”Œλ‘œλ₯Ό νŠΈλ¦¬κ±°ν•˜λ €λŠ” 경우

schedule

POSIX cron ꡬ문을 μ‚¬μš©ν•˜μ—¬ νŠΉμ • UTC μ‹œκ°„μ— μ›Œν¬ν”Œλ‘œλ₯Ό μ‹€ν–‰ν•˜λ„λ‘ μ˜ˆμ•½

status

Git μ»€λ°‹μ˜ μƒνƒœκ°€ 변경될 λ•Œ

watch

μ›Œν¬ν”Œλ‘œμ˜ 리포지토리가 λ³„ν‘œλ‘œ ν‘œμ‹œλ˜λ©΄

workflow_call

λ‹€λ₯Έ μ›Œν¬ν”Œλ‘œμ—μ„œ μ›Œν¬ν”Œλ‘œλ₯Ό ν˜ΈμΆœν•  수 μžˆμŒμ„ λ‚˜νƒ€λ‚΄λŠ” 데 μ‚¬μš©

workflow_dispatch

μ›Œν¬ν”Œλ‘œμš°κ°€ μˆ˜λ™μœΌλ‘œ νŠΈλ¦¬κ±°λ˜λ„λ‘ ν•˜κΈ°μœ„ν•΄ μ‚¬μš©

workflow_run

μ›Œν¬ν”Œλ‘œ 싀행을 μš”μ²­ν•˜κ±°λ‚˜ μ™„λ£Œν•  λ•Œ λ°œμƒ

μž‘μ—…(jobs)

λ™μΌν•œ λŸ¬λ„ˆμ—μ„œ μ‹€ν–‰λ˜λŠ” μ›Œν¬ν”Œλ‘œμ˜ 일련의 λ‹¨κ³„λ‘œ

각 λ‹¨κ³„λŠ” shell script λ˜λŠ” action이며 μˆœμ„œλŒ€λ‘œ μ‹€ν–‰λœλ‹€

단계(step) κ°„μ—λŠ” μ„œλ‘œ 쒅속적이며 데이터λ₯Ό κ³΅μœ ν•  수 μžˆλ‹€

jobs:
  my_first_job:
    name: My first job
  my_second_job:
    name: My second job

반면 μž‘μ—… κ°„μ—λŠ” 기본적으둜 쒅속성이 μ—†κ³ , λ³‘λ ¬λ‘œ μ‹€ν–‰λœλ‹€. νŠΉμ • μž‘μ—…μ΄ λ‹€λ₯Έ μž‘μ—… 이후에 μ‹€ν–‰λ˜μ–΄μ•Ό ν•œλ‹€λ©΄ needsλ₯Ό 톡해 쒅속성을 지정해야 ν•œλ‹€

jobs:
  job1:
  job2:
    needs: job1
  job3:
    needs: [job1, job2]

μ•‘μ…˜(actions)

자주 λ°˜λ³΅λ˜λŠ” λ³΅μž‘ν•œ μž‘μ—…μ„ μž¬μ‚¬μš©ν•˜λ„λ‘ λ§Œλ“  Github Actions ν”Œλž«νΌ μ „μš© μ‚¬μš©μž 지정 μ• ν”Œλ¦¬μΌ€μ΄μ…˜

λ§ˆμΌ“ν”Œλ ˆμ΄μŠ€ https://github.com/marketplace

μ•‘μ…˜μ˜ μ˜ˆμ‹œ

  • Githubμ—μ„œ Git λ¦¬ν¬μ§€ν† λ¦¬κ°€μ Έμ˜€κΈ°(checkout)

  • λΉŒλ“œλ₯Ό μœ„ν•œ 도ꡬ μ„€μ •(setup)

  • ν΄λΌμš°λ“œ κ³΅κΈ‰μžμ— λŒ€ν•œ 인증

λŸ¬λ„ˆ(runner)

μ›Œν¬ν”Œλ‘œλ₯Ό μ‹€ν–‰ν•˜λŠ” μ„œλ²„. 각 μ„œλ²„λŠ” ν•œ λ²ˆμ— ν•˜λ‚˜μ˜ μž‘μ—…μ„ μ‹€ν–‰

name

μ›Œν¬ν”Œλ‘œμ˜ μ΄λ¦„μœΌλ‘œ Github λ¦¬ν¬μ§€ν† λ¦¬μ˜ "Actions" νƒ­μ—μ„œ ν‘œμ‹œν•  λ•Œ μ‚¬μš©

μƒλž΅ν•˜λ©΄ μ›Œν¬ν”Œλ‘œ 파일 경둜λ₯Ό μ‚¬μš©ν•˜μ—¬ ν‘œμ‹œ

name: hello-world

run-name

μ›Œν¬ν”Œλ‘œμ—μ„œ μƒμ„±λœ 싀행에 λŒ€ν•œ 이름

μƒλž΅ν•˜λ©΄ 싀행에 λŒ€ν•œ 이벀트 μ •λ³΄λ‘œ μ„€μ •

on

μ›Œν¬ν”Œλ‘œλ₯Ό μžλ™μœΌλ‘œ νŠΈλ¦¬κ±°ν•˜κΈ° μœ„ν•œ 이벀트λ₯Ό μ •μ˜

  • 이벀트 μ •μ˜ν•˜κΈ°

  • μ‹œκ°„ μ„€μ •ν•˜κΈ°

  • νŠΉμ • 파일, νƒœκ·Έ, λΆ„κΈ°μ—μ„œλ§Œ μ›Œν¬ν”Œλ‘œκ°€ μ‹€ν–‰λ˜λ„λ‘ μ œν•œν•˜κΈ°

https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows

on: push

jobs

μ›Œν¬ν”Œλ‘œ 싀행은 λ³‘λ ¬λ‘œ μ‹€ν–‰λ˜λŠ” ν•˜λ‚˜ μ΄μƒμ˜ jobs둜 ꡬ성

μž‘μ—…μ€ ν•˜λ‚˜ μ΄μƒμ˜ 단계(steps)둜 ꡬ성

jobsλŠ” jobs.<job_id>.runs-onμ—μ„œ μ‹€ν–‰λœλ‹€

jobs.<job_id>.needs을 톡해 μž‘μ—…μ„ 순차적으둜 μ‹€ν–‰ν•˜λ„λ‘ μž‘μ—…μ— λŒ€ν•œ 쒅속성을 μ •μ˜ν•  수 μžˆλ‹€

jobs: 
  hello-world-job:

    runs-on: ubuntu-latest

    steps: 
      - name: Check out repository code
        uses: actions/checkout@v3
      - run: echo "$(cat hello_world.txt)"

jobs.<job_id>.runs-on

μž‘μ—…μ„ μ‹€ν–‰ν•  λ¨Έμ‹  μœ ν˜•μ„ μ •μ˜

κΉƒν—ˆλΈŒ ν˜ΈμŠ€νŒ… λŸ¬λ„ˆ, 더 큰 λŸ¬λ„ˆ, 자체 ν˜ΈμŠ€νŒ… λŸ¬λ„ˆ μ€‘μ—μ„œ μ‚¬μš© ν•  수 있음

jobs: 
  hello-world-job:
    runs-on: ubuntu-latest

κΉƒν—ˆλΈŒ ν˜ΈμŠ€νŒ… λŸ¬λ„ˆ

  • ubuntu-latest

  • windows-latest

  • macos-latest

Checkout

λ¦¬ν¬μ§€ν† λ¦¬μ˜ μ½”λ“œλ₯Ό κ²€μƒ‰ν•˜κ³  μ›Œν¬ν”Œλ‘œμ—μ„œ λ¦¬ν¬μ§€ν† λ¦¬μ˜ μ½˜ν…μΈ μ— μ•‘μ„ΈμŠ€ κ°€λŠ₯ν•˜λ„λ‘ 체크 아웃

https://github.com/marketplace/actions/checkout

   - name: Check out repository code
     uses: actions/checkout@v3
   - run: echo "$(cat hello_world.txt)"

Nodejs ν™˜κ²½ ꡬ성 및 λΉŒλ“œ

https://github.com/marketplace/actions/setup-node-js-environment

https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

Nodejs ν™˜κ²½ ꡬ성 및 λΉŒλ“œ job

  build:
    runs-on: ubuntu-latest
    steps: 
      - name: checkout repo
        uses: actions/checkout@v3
      - name: use node.js
        uses: actions/setup-node@v3
        with:
          node-version: '18.x'
      - run: npm install
      - run: npm run build 

ν…ŒμŠ€νŠΈ job

  test: 
    needs: build
    runs-on: ubuntu-latest
    steps: 
      - name: checkout repo
        uses: actions/checkout@v3
      - name: use node.js
        uses: actions/setup-node@v3
        with:
          node-version: '18.x'
      - run: npm install
      - run: npm test

μ—¬λŸ¬ ν™˜κ²½ λ™μ‹œ 병렬 ν…ŒμŠ€νŠΈ

배열을 μ‚¬μš©ν•˜μ—¬ μš΄μ˜μ²΄μ™€κ³Ό 버전을 μ§€μ •ν•˜λ©΄, ν•΄λ‹Ήν•˜λŠ” ν™˜κ²½μ— λŒ€ν•΄μ„œ λ™μ‹œμ— ν…ŒμŠ€νŠΈν•˜μ—¬ μ‹œκ°„ μ ˆμ•½

jobs:
  example_matrix:
    strategy:
      matrix:
        version: [10, 12, 14]
        os: [ubuntu-latest, windows-latest]
{version: 10, os: ubuntu-latest}
{version: 10, os: windows-latest}
{version: 12, os: ubuntu-latest}
{version: 12, os: windows-latest}
{version: 14, os: ubuntu-latest}
{version: 14, os: windows-latest}

secrets μ‚¬μš©

repository -> Settings -> Security -> Actions secrets and variables

https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions

${{ secrets.MY_GITHUB_SECRET }}

Last updated