Github Actions - Matrix & Secrets

๋ฐ˜์‘ํ˜•

์ด๋ฒˆ์—๋Š” Matrix๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋‹ค์ค‘ OS ํ™˜๊ฒฝ, ๋‹ค์–‘ํ•œ ๋ฒ„์ „์˜ ์–ธ์–ด, ํ”„๋ ˆ์ž„์›Œํฌ ๋“ฑ์„ ํ™œ์„ฑํ™” ์‹œํ‚ค๋Š” ์›Œํฌํ”Œ๋กœ์šฐ๋ฅผ ์ž‘์„ฑํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

 

Matrix

Matrix๋Š” Array์™€ ์œ ์‚ฌํ•ฉ๋‹ˆ๋‹ค. YAML์—์„œ๋Š” ํŠน์ • ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ, ์ด๋ฅผ ๋ณต์ˆ˜๊ฐœ๋กœ ์„ ์–ธํ•˜๊ณ  ์‹ถ์„ ๊ฒฝ์šฐ์—๋Š” Matrix๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋งˆ ๊ธฐ์กด์˜ Travis CI๋ฅผ ์จ๋ณด์‹  ๋ถ„๋“ค์ด๋ผ๋ฉด ์ต์ˆ™ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

name: Practice actions

on:
  push:
    branches:
      - master

  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version: [2.7, 3.5, 3.6, 3.7]
    
    steps:
      - uses: actions/checkout@v1
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v1
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies...
        run: python -m pip install --upgrade pip  # Instead of APT for debian package manager

๊ธฐ์กด์— ์‚ฌ์šฉํ–ˆ๋˜ Workflow๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•˜์—ฌ master ๋ธŒ๋žœ์น˜์— Push, PR์„ ๊ธฐ๋ณธ ์ด๋ฒคํŠธ๋กœ ๋‘๊ณ , Python ์–ธ์–ด์—์„œ ์ž‘์—…ํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. Python ๋ฒ„์ „์€ ์ƒ๊ฐ๋ณด๋‹ค ๋งŽ๊ธฐ ๋–„๋ฌธ์— ์—ฌ๋Ÿฌ ๋ฒ„์ „์—์„œ ํ˜ธํ™˜์„ ์›ํ•œ๋‹ค๋ฉด ๊ฐ ๋ฒ„์ „์—์„œ ํ…Œ์ŠคํŠธํ•ด์•ผ ํ•  ํ•„์š”๊ฐ€ ์ƒ๊ธฐ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. 

 

์ด๋Ÿด ๋•Œ๋Š” Github Actions์—์„œ ์ œ๊ณตํ•˜๋Š” setup ๋ ˆํฌ์ง€ํ„ฐ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•ด๋‹น ๋ ˆํฌ์ง€ํ„ฐ๋ฆฌ์—์„œ ์ œ๊ณตํ•˜๋Š” Python Setup ํŒจํ‚ค์ง€๋ฅผ steps์— ์ถ”๊ฐ€ํ•˜๊ณ , with ๋ฐ˜๋ณต๋ฌธ์„ ์‚ฌ์šฉํ•˜๋ฉด, matrix์—์„œ ๋ณธ์ธ์ด ์ •์˜ํ•œ ๋ฒ„์ „์„ ์„ค์น˜ํ•ด์ค๋‹ˆ๋‹ค.

 

๊ทธ๋Ÿฌ๋ฉด ์™ผ์ชฝ์— ๋ณด์‹œ๋Š” ๊ฒƒ๊ณผ ๊ฐ™์ด ๋นŒ๋“œ ํ™˜๊ฒฝ์ด ๋ฒ„์ „๋ณ„๋กœ ๋‚˜์—ด์ด ๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ, ๊ผญ ๊ตณ์ด step์„ ๋ฐŸ์„ ๋•Œ Github Actions์—์„œ ์ œ๊ณตํ•˜๋Š” ์ฝ”๋“œ๋งŒ ์จ์•ผํ• ๊นŒ์š”? ๋ฌผ๋ก  ๊ทธ๊ฒƒ์€ ์•„๋‹™๋‹ˆ๋‹ค. ์ด ์ฝ”๋“œ๋Š” ๋ณด๋‹ค์‹œํ”ผ OS ํ™˜๊ฒฝ์„ Ubuntu๋กœ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๊ณ , ๋นŒ๋“œ ํ™˜๊ฒฝ ๋˜ํ•œ Travis CI๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— Debian์—์„œ ์ œ๊ณตํ•˜๋Š” apt package manager๋ฅผ ์‚ฌ์šฉํ•ด๋„ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. 

name: Practice actions

on:
  push:
    branches:
      - master

  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      max-parallel: 4
      matrix:
        python-version: [2.7, 3.5, 3.6, 3.7]
        os: [ubuntu-latest, windows-latest, macOS-latest]
    
    steps:
      - uses: actions/checkout@v1
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v1
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies...
        run: python -m pip install --upgrade pip  # Instead of APT for debian package manager

์ถ”๊ฐ€๋กœ OS์— ๋Œ€ํ•ด์„œ๋„ ์œ„์™€ ๊ฐ™์ด Matrix๋ฅผ ์ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

ํŒจ๋Ÿฌ๋ž ๋ฅผ ํ™œ์„ฑํ™” ์‹œ์ผฐ๋”๋‹ˆ ํ™˜๊ฒฝ ๋งŒ๋“œ๋Š” ์ž‘์—…์ด ๊ทธ๋ ‡๊ฒŒ ์˜ค๋ž˜ ๊ฑธ๋ฆฌ์ง„ ์•Š๋„ค์š”.. ์ „๋ถ€ ๋‹ค ํ•ด์„œ ํ•œ 5๋ถ„ ์ •๋„ ์†Œ์š”๋œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. 

์ด๋ฅผ ์‘์šฉํ•ด์„œ Java, Javascript ๋“ฑ์˜ ์–ธ์–ด๋„ ๋™์ผํ•˜๊ฒŒ ์›Œํฌํ”Œ๋กœ์šฐ๋ฅผ ๋งŒ๋“œ์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

 

Secrets

๋‹ค์Œ์€ Secrets์ž…๋‹ˆ๋‹ค. Secrets๋Š” ๋งค์šฐ ์ค‘์š”ํ•˜์ฃ . ์—ฌ๋Ÿฌ๋ถ„๋“ค์ด ๋งŒ์•ฝ, PR Workflow์—์„œ ๊ธฐ๋ณธ์ ์ธ ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๊ณ , ์ด๊ฒƒ์ด Merge๊ฐ€ ์ด๋ฃจ์–ด์ง€๋ฉด ๋ฐฐํฌ๋ฅผ ํ•ด์•ผ๊ฒ ์ฃ ? Git flow๋ฅผ ์˜ˆ๋กœ ๋“ค์—ˆ์„ ๋•Œ, develop์ด ๋๋‚˜๋ฉด, Test ํ›„, Production์œผ๋กœ ๊ฐ€๋Š” ๊ฒƒ๊ณผ ๋น„์Šทํ•œ ์ƒํ™ฉ์ธ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

ํ•˜์ง€๋งŒ On-Premise ํ™˜๊ฒฝ์—์„œ ๋ฐฐํฌ๋ฅผ ํ•˜๋Š” ๊ฒƒ์ด๋ผ๋ฉด, IP ์ฃผ์†Œ๊ฐ€ ๊ฐ€์žฅ ๋ฏผ๊ฐํ•œ ์‚ฌํ•ญ์ผ ๊ฒƒ์ด๊ณ , VPN์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ๊ทธ์— ์ž…๋ ฅ๋˜๋Š” ๊ณ„์ •์‚ฌํ•ญ์ด ์ตœ์ƒ์˜ ๋ณด์•ˆ ์ •๋ณด์— ํ•ด๋‹น๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์•ˆ์ „ํ•œ ํ”„๋กœํ† ์ฝœ์ด๋‚˜ Secure Layer๋ฅผ ์ ์šฉํ–ˆ๋‹ค ํ•˜๋”๋ผ๋„ ์ด๋“ค์ด ๊ฐ™์ด ๋ ˆํฌ์ง€ํ„ฐ๋ฆฌ์— ๊ณต์œ ๋œ ์ƒํƒœ๋กœ ์žˆ๋‹ค๋ฉด ๊ฒ€์ƒ‰ ์—”์ง„ ํ™˜๊ฒฝ์— ๋…ธ์ถœ์ด ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๋Š” ๊ฒฐ์ฝ” ๊ถŒ์žฅํ•˜์ง€ ์•Š๋Š” ์‚ฌํ•ญ ์ค‘์— ํ•˜๋‚˜์ž…๋‹ˆ๋‹ค.

 

Travis CI์—์„œ๋Š” ์ž์ฒด์ ์œผ๋กœ Virtual Environment๋ฅผ ์ œ๊ณตํ•˜์—ฌ ๋ฏผ๊ฐํ•œ ์ •๋ณด๋ฅผ ๋ณด๊ด€ํ•  ์ˆ˜ ์žˆ๋Š” ๊ณณ์ด ์žˆ์—ˆ์ฃ . Github์—์„œ ๋˜ํ•œ ์ด๋Ÿฌํ•œ ๊ฐ€์ƒ ํ™˜๊ฒฝ์„ ์ œ๊ณตํ•˜์—ฌ ๋ฏผ๊ฐํ•œ ์ •๋ณด๋ฅผ ์•ˆ์ „ํ•˜๊ฒŒ ๋ณด๊ด€ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

๋ ˆํฌ์ง€ํ„ฐ๋ฆฌ์˜ ์„ค์ •์— ๊ฐ€๋ฉด Secrets ๋ฉ”๋‰ด๊ฐ€ ์ƒ๊ฒจ์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. Secrets ๋ฉ”๋‰ด์—์„œ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์•”ํ˜ธํ™”ํ•˜์—ฌ Actions์— ์ œ๊ณต์„ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ณด๋‹ค ์•ˆ์ „ํ•˜๊ฒŒ ํด๋ผ์šฐ๋“œ์˜ IAM ์ธ์ฆ ์ •๋ณด ๋“ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ API๋กœ ์‰ฝ๊ฒŒ ๋ฐฐํฌํ•˜๋Š” ํ™˜๊ฒฝ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

name: Practice actions

on:
  push:
    branches:
      - master

  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      max-parallel: 4
      matrix:
        python-version: [2.7, 3.5, 3.6, 3.7]
        os: [ubuntu-latest, windows-latest, macOS-latest]
    
    steps:
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v1
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies...
        run: python -m pip install --upgrade pip  # Instead of APT for debian package manager
      - name: Download for changes...
        uses: actions/checkout@v1
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

ํ™˜๊ฒฝ๋ณ€์ˆ˜๋ฅผ ๋ถ€๋ฅด๋Š” ๋ฐฉ๋ฒ•์€ secrets ๋ผ๋Š” ๊ฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ๋ฐฐํฌ ํ™˜๊ฒฝ์„ ๋งŒ๋“œ๋Š” ๊ฒƒ๋„ ๋ฌธ์ œ ์—†์ด Actions๋ฅผ ์ด์šฉํ•ด์„œ ์‰ฝ๊ฒŒ ๋งŒ๋“œ์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๋‹ค์Œ ๊ธ€์—์„œ๋Š” React ํ”„๋กœ์ ํŠธ + Firebase Deploy ํ™˜๊ฒฝ์„ ์‚ฌ์šฉํ•œ ์ž๋™ ๋ฐฐํฌ ํ™˜๊ฒฝ์„ ๋งŒ๋“œ๋Š” ์‹œ๊ฐ„์„ ๊ฐ€์ง€๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

๋ฐ˜์‘ํ˜•
TAGS.

Tistory Comments