Github Actions๋ ์ข๋ค.
6110 ๋จ์ด SSHGitHubActionsGitHub
GitHub Actions๋ฅผ ์ฌ์ฉํ๊ธฐ ์์ํ์ต๋๋ค.
์ง๊ธ๊น์ง CodeCommit์ ์ฌ์ฉํ์ฌ ๋ฆฌ์์ค ๊ด๋ฆฌ๋ฅผ ํ๊ณ ์์์ต๋๋ค๋ง, ๋ฉค๋ฒ๋ก๋ถํฐ ํ๋ฆญ ๋ณด๊ธฐ ์ด๋ ต๋ค๊ณ ๋ถํ์ด ์์์ผ๋ฏ๋ก, CodeCommit์์ GitHub๋ก ํ์นํ์ต๋๋ค.
๊ทธ ๊ณผ์ ์์ ์์ํ๊ฒ ํ๊ณ ์๋ ๊ฐ๋ฐ ๊ธฐ๋ฐ์ด๋ ๋ฆด๋ฆฌ์ค ๊ธฐ๋ฐ์ ์ ๋น๋ฅผ ํ๊ณ ์์ต๋๋ค๋ง, ๊ทธ ์ค์์ ์๋์ผ๋ก ๋ฐฐํฌํ๋ ๊ฒ์ ๊ท์ฐฎ๋ค์, ๋ผ๊ณ ํ๋ ์ด์ผ๊ธฐ๊ฐ ๋์ด, ๋ชจ์ฒ๋ผ์ด๋ฏ๋ก ์๋ ๋ฐฐํฌ๋ฅผ ๋์ ํ๊ฒ ๋์ด, ๊ทธ ์์์ ์ฌ์ฉํ๋ ํ๋ณด์ ์ค๋ฅธ ๊ฒ์ด GitHub Actions์ ๋๋ค.
GitHub Actions์ ์ง๊ฒฌ์ ๊ฑฐ์ ์์์ต๋๋ค๋ง, ์ฐฉ์ํ๊ณ ๋์ 1~2์๊ฐ ์ ๋๋ก ์๋ ๋ฐฐํฌ์ Action์ ํ ์ ์์์ผ๋ฏ๋ก, ์ฌ๊ธฐ์์ ์ฌ๋ฌ๋ถ์๊ฒ ๊ทธ ์ฅ์ ์ ์๊ฐํ๋ ค๊ณ ์๊ฐํฉ๋๋ค.
GitHub Actions์ ํธ๋ฆฌํจ
์ค์ ๋ก ์ฌ์ฉํด ๋ณด๊ณ ํนํ ํธ๋ฆฌํ๋ค๊ณ ์๊ฐํ ํน์ง์ด ์ดํ์ ๋๋ค.
job์ด yaml๋ก ์ธ ์ ์์ต๋๋ค.
YAML LOVE์ ๋์๊ฒ ์ด๊ฒ์ ๊ธฐ์๋ค.
GitHub Actions์ ์ค์ ์ ๋ฆฌํฌ์งํ ๋ฆฌ ์ดํ,
.github/workflows
๋๋ ํ ๋ฆฌ์ YAML ํ์ผ์ ๋๊ณ , GitHub์์ ๋ฆฌํฌ์งํ ๋ฆฌ์ push ํ๋ ๊ฒ๋ง์ผ๋ก ์๊ฒฐํฉ๋๋ค.์ดํ, ํ ๋ก์
github/workflows/sample.yml
# This is a basic workflow to help you get started with Actions
name: Deploy
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ develop ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
sample-deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# task
- name: echo
run: echo "Hello World"
YAML์ ์ด๋ ์ ๋ ๋ค๊ณ ์๋ ์ฌ๋์ ์ง๊ด์ ์ผ๋ก ํ์คํฌ๋ฅผ ์์ํ ์ ์๋ ๊ฒ์ ์ ์ ์์๊น ์๊ฐํ๊ณ , ๊ตฌ๋ฌธ๋ ๋งค์ฐ ์๊ธฐ ์ฝ๊ณ ์ข๋ค. ์ข์.
์ฝ๊ฒ GitHub์ ์ฐ๋ ๊ฐ๋ฅ
GitHub Actions๋ฅผ ์ฌ์ฉํ๋ ์ด์, ๋ธ๋์น์ merge๋ push๋ฅผ ๊ณ๊ธฐ๋ก ํ๊ณ ์ถ์ ๊ฒ์ด ๋๋ถ๋ถ์ ๋๋ค๋ง, ๊ทธ ์ ์ GitHub Actions์ ๊ธฐ์ ์ ๊ฝค ๊ฐ์ดํ๋๊ณ ์์ต๋๋ค.
github/workflows/sample.yml
# developใธใฎpushใๅฅๆฉใซๅฎ่ก
on:
push:
branches: [ develop ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
sample-deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# developใใฉใณใใ$GITHUB_WORKSPACEใซcheckout
- uses: actions/checkout@v2
git ๋ช ๋ น์ด๋ GitHub API๋ฅผ ์จ๋ ์ข์ง๋ง, ์ค๋ ์ฐ๋ ๊ฒ๋ณด๋ค ์๊ธฐ ์ฝ๊ณ ๋๋ํ๋ค์.
GitHub์์ ์ ๊ณตํ๋ ๊ฐ์ ๋จธ์ ์์ ์คํ
GitHub Actions๊ฐ ์คํ๋๋ฉด ๊ฐ์ ๋จธ์ ์ด ํ๋ ์์ฑ๋๊ณ ๊ทธ ์์ Actions๊ฐ ์คํ๋ฉ๋๋ค.
runs-on: ubuntu-latest
์์ Ubuntu ์ด๋ฏธ์ง๊ฐ ์ฌ์ฉ๋๊ณ ์์์ ์ ์ ์์ต๋๋ค.๋ฐ๋ผ์ Ubuntu์์ ์ฌ์ฉํ ์ ์๋ ๋ช ๋ น์ ์ฌ์ฉํ์ฌ ๋ฐฐํฌ ์ค๋น ์์ /๋ฐฐํฌ ์์ ์ ์ ์ํ ์ ์์ต๋๋ค. tar๋ scp๋ ๋๋ถ๋ถ์ ๋ช ๋ น์ด ์์ง์ ๋๋ค. ์ธ์คํด์ค ์ค๋น๋ ํ์ ์์.
# Archive
- name: archive package
run: tar zcvf sample.tgz sample/*
ํ์ฌ Windows/Ubuntu/MacOS๋ฅผ ์ฌ์ฉํ ์ ์๋ ๋ชจ์. ์์ธํ ๋ด์ฉ์ ์๋ URL์ runs-on ํญ๋ชฉ์ ํ์ธํ์ญ์์ค.
htps : // ์ lp. ๊ธฐ์ฃผ b. ์ฝ m / ์ / ์ c ์น์จ s / ๋ ํ ๋ ์ธ /
Secrets๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
AWS ๋ฆฌ์์ค์ ์ก์ธ์คํ๊ณ ์ถ์
SCP
๋๋ SSH
ํ๊ณ ์ถ์ ๊ฒ๋ ์์๊น ์๊ฐํฉ๋๋ค.ํ์ง๋ง, ๋น๋ฐํค๋ DB์ ์ ์ ์ ๋ณด๋ฑ์ ํฌ์งํ ๋ฆฌ์ ๋ฃ๋ ๊ฒ์ ๊ทนํ์ ๊ฐ์น๊ฐ ์์ผ๋ฏ๋ก, ๊ทธ ๋์ ์ฌ์ฉํ๋ ๊ฒ์ด ๋ฆฌํฌ์งํฐ๋ฆฌ๋ก ์ค์ ํ๋ Secrets์ ๋๋ค.
๋งํ์๋ฉด, ๋ฆฌํฌ์งํ ๋ฆฌ ํ๊ฒฝ ๋ณ์์ ๊ฐ์ ๊ฒ์ผ๋ก, ํ ๋ฒ ์ค์ ํ๋ฉด ๊ฐ์ ๋๊ตฌ๋ก๋ถํฐ๋ ๋ค์ฌ๋ค ๋ณผ ์ ์๊ฒ ๋๋ฏ๋ก ๋งค์ฐ ํธ๋ฆฌ. ๋ฆฌํฌ์งํ ๋ฆฌ์ ์ค์ ์์ ์ค์ ํ ์ ์์ต๋๋ค.

๊ทธ๋์ GitHub Actions๋ ๊ทธ Secrets๋ฅผ ์ด์ฉํ ์ ์์ต๋๋ค. ์ฐ๋ ๋ฐฉ๋ฒ์ ์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
${{ secrets.(HOST_PASSWORD)}}
SSH์ ๋น๋ฐ ํค๋ Secrets์ ์จ ๋๊ณ , Actions ์คํ์์ id_rsa ํ์ผ์ ์ถ๋ ฅํด ์ฌ์ฉํ๋, ์ด๋ค ์ผ์ ํ๋ ๋ฐฉ๋ฒ๋ ์์ต๋๋ค.
โป ์ฐธ๊ณ : GitHub์ ์๋ก์ด ๊ธฐ๋ฅ "GitHub Actions"์์ ์ํ CI / CD
run: echo "${{ secrets.SECRET_KEY }}" > id_rsa && chmod 600 id_rsa
์์ฝ
์ด๋ฌํ ๋ฐฉ์์ผ๋ก GitHub์ ๋ฆฌํฌ์งํ ๋ฆฌ์ ๋ํ ์ก์ธ์ค, ๋ฐฐํฌ ์์ ๊ด๋ฆฌ ๋ฐ ์คํ ๊ด๋ฆฌ๊ฐ ๋ชจ๋ GitHub์์ ์๋ฃ๋ฉ๋๋ค. CI/CD ํ๊ฒฝ์ ๋ง๋ค๊ณ ์ถ์์ง๋ง, Jenkins์ ๊น๋ค๋ก์ด, ๋ค๋ฅธ ์ฌ๋์ ๋์ด ๋ ๋ค๊ณ ์๊ฐํ๋ ๋ถ์๊ฒ๋ ์ถ์ฒ์ ๋๋ค.
์ผ๋จ, ํ๋ฆฌ ํ๋์ ์คํ ์๊ฐ 2000๋ถ/์๊น์ง ๋ฌด๋ฃ์ธ ๊ฒ ๊ฐ๊ธฐ ๋๋ฌธ์ ๊ทธ๋ฐ ๋ฌด๊ฑฐ์ด ์ฒ๋ฆฌ๊ฐ ์๋๋ฉด ๊ฒฌ๋ ์ ์์๊น ์๊ฐํฉ๋๋ค. ๊ผญ ์๋ํด๋ณด์ญ์์ค.
Reference
์ด ๋ฌธ์ ์ ๊ดํ์ฌ(Github Actions๋ ์ข๋ค.), ์ฐ๋ฆฌ๋ ์ด๊ณณ์์ ๋ ๋ง์ ์๋ฃ๋ฅผ ๋ฐ๊ฒฌํ๊ณ ๋งํฌ๋ฅผ ํด๋ฆญํ์ฌ ๋ณด์๋ค https://qiita.com/ajitator/items/6be389face0a68969bfbํ ์คํธ๋ฅผ ์์ ๋กญ๊ฒ ๊ณต์ ํ๊ฑฐ๋ ๋ณต์ฌํ ์ ์์ต๋๋ค.ํ์ง๋ง ์ด ๋ฌธ์์ URL์ ์ฐธ์กฐ URL๋ก ๋จ๊ฒจ ๋์ญ์์ค.
์ฐ์ํ ๊ฐ๋ฐ์ ์ฝํ
์ธ ๋ฐ๊ฒฌ์ ์ ๋
(Collection and Share based on the CC Protocol.)
์ข์ ์นํ์ด์ง ์ฆ๊ฒจ์ฐพ๊ธฐ
๊ฐ๋ฐ์ ์ฐ์ ์ฌ์ดํธ ์์ง
๊ฐ๋ฐ์๊ฐ ์์์ผ ํ ํ์ ์ฌ์ดํธ 100์ ์ถ์ฒ ์ฐ๋ฆฌ๋ ๋น์ ์ ์ํด 100๊ฐ์ ์์ฃผ ์ฌ์ฉํ๋ ๊ฐ๋ฐ์ ํ์ต ์ฌ์ดํธ๋ฅผ ์ ๋ฆฌํ์ต๋๋ค