Github Actions - ๊ฐ๋จํ ์ํฌํ๋ก์ฐ ์์ฑํด๋ณด๊ธฐ
์ง๋ ํฌ์คํธ์์ Github Actions์ ๋ํ ๊ฐ๋จํ ์ฌ์ฉ๊ณผ ๊ธฐ๋ฅ์ ์๊ฐํ๋ ์๊ฐ์ ๊ฐ์ก์๋๋ฐ์. ์ด๋ฒ์๋ ์ง์ Github Actions๋ฅผ ์ฌ์ฉํด ์ํฌํ๋ก์ฐ๋ฅผ ์๋ํํ๋ ๊ฒ์ ํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
Start
๋จผ์ ๋ ํฌ์งํฐ๋ฆฌ๋ฅผ Actions๋ฅผ ์ฌ์ฉํ๊ณ ์ ํ๋ ํ๋ก์ ํธ๋ฅผ clone ํ๋๋ก ํ์ฃ .
$ git clone [Repository]
ํด๋ก ํ ๋ ํฌ์งํฐ๋ฆฌ์ ์๋์ ๋๋ ํฐ๋ฆฌ๋ฅผ ํ ๊ฐ ๋ง๋ค์ด๋ณด๊ฒ ์ต๋๋ค.
$ mkdir -p .github/workflows
Actions๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ๋จผ์ Workflow๋ฅผ ์ฝ์ ์ ์๋ ๊ฒฝ๋ก๊ฐ ํ์ํ๋ฐ, ์ด ๊ฒฝ๋ก๊ฐ ๋ฐ๋ก .github ๋๋ ํฐ๋ฆฌ์ ๋๋ค.
$ touch main.yml
๊ทธ๋ฆฌ๊ณ main.yml ๋ผ๋ ์ด๋ฆ์ ํ์ผ์ ํ ๊ฐ ๋ง๋ค์ด์ค๋๋ค. ์ด๊ฒ์ด ์ด ๋ ํฌ์งํฐ๋ฆฌ์์ Maintain์ผ๋ก ์๋ํ๋ Workflow ์ค ํ๋์ ๋๋ค.
.
โโโ ,git
โโโ .github
โโโ workflows
โโโ main.yml
โโโ config
โโโ public
โโโ src
๋๋ ํฐ๋ฆฌ ํธ๋ฆฌ๋ฅผ ๋ณด๋ฉด, ๋์ถฉ ์ด๋ฐ ํ์์ด๋ค. React ํ๋ก์ ํธ๋ง๋ค ์กฐ๊ธ์ ๋ค๋ฅผ ์ ์๊ฒ ์ง๋ง ๊ธฐ๋ณธ์ ์ผ๋ก Git์ ๋ถ์ด๊ฒ ๋๋ฉด .git ํด๋๊ฐ ์๊ณ , Actions๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด์๋ .github ํด๋๋ฅผ ๋ง๋ค์ด์ Workflow ์ฝ๋๋ฅผ ์ฝ์ ํ๋ฉด Actions๊ฐ ๋์ํ๊ฒ ๋๋ ๊ตฌ์กฐ์ธ ๊ฒ์ด์ฃ .
Write Actions
์ด์ ์ํฌํ๋ก์ฐ๋ฅผ ์ ์ํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค. ์๋ํ ์ฝ๋๋ฅผ ์์ฑํ๊ธฐ ์ํด ์๋์ ๊ฐ์ด๋๋ผ์ธ์ ์ฐธ์กฐํ์์ต๋๋ค.
Configuring a workflow - GitHub Help
Configuring a workflow You can create, view, or edit workflows for a repository if you have write or admin permissions to the repository. You can customize your workflow configuration based on the type of actions you include in your workflow. GitHub Action
help.github.com
๊ทธ๋ผ ๊ฐ๋จํ ์ฝ๋๋ฅผ ์ง๋ณด๋๋ก ํ์ฃ .
name: Practice actions
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Run a one-line script
run: echo Testing...
name ์์ญ์ ์์ ์ Workflow ์ด๋ฆ์ ๋ฃ๋๋ก ํฉ๋๋ค. ๊ทธ ํ ์ด๋ค ๋ธ๋์น์์ ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ์ ๋ Workflow๋ฅผ ์ํํ ์ง๋ฅผ ๊ณ ๋ฅด๊ณ , ๋ง์ง๋ง์ผ๋ก ์ด๋ค ์์ ์ ์ด๋ OS์์ ์ํํ ๊ฒ์ธ์ง๋ฅผ ์ ํ๋ฉด ๊ธฐ๋ณธ ์ํฌํ๋ก์ฐ ํ์ด ์์ฑ๋ฉ๋๋ค.
์ํฌํ๋ก์ฐ๊ฐ ์์ฑ์ด ๋ ์ํ๋ก ์๊ฒฉ ์ ์ฅ์์ Push๋ฅผ ํ๊ฒ ๋๋ฉด ์์ ๊ฐ์ด ์์ ํ ๋ด์ฉ๊ณผ Actions์ ์ด๋ฆ์ด ํ์๊ฐ ๋ฉ๋๋ค. ์? ๊ทธ๋ฐ๋ฐ, Actions๋ฅผ ์์ธํ ๋ณด๋, ๋น๋ ํ๊ฒฝ์ผ๋ก Travis CI๋ฅผ ์ฌ์ฉํ๊ณ ์๋ ๊ฒ์ด ๋์ ๋๋ค์..
๊ทธ๋ฌ๋ฉด ๊ฐ๋จํ ์๊ณ ๋ฆฌ์ฆ์ ํ ๊ฐ ์ง๋ณด๊ณ , ํด๋น ์๊ณ ๋ฆฌ์ฆ์ด ์ ๋์๊ฐ๋์ง๋ฅผ ํ ๋ฒ ํ ์คํธํด๋ณด๋ Workflow๋ฅผ ํ ๋ฒ ์ง๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค. ์ธ์ด๋ C++๋ก ํ ๋ฒ ์ง๋ณด๋๋ก ํ ๊ฒ์.
name: Practice actions
on:
push:
branches:
- master
on:
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run cmake for create configuration,,
run: cmake CMakeLists.txt
- name: Run make command,,
run: make
- name: Test code,,
run: ./Multitab
์ด๋ฒ์๋ ์ถ๊ฐ๋ก master์ push ํ๋ ๊ฒ ๋ฟ ์๋, PR์ ๋ํด์๋ ์ ์ฉ์ ํด๋ดค์ต๋๋ค. uses์ ๋ฐ๋์ checkout@v1 ๊ธฐ๋ก์ ๋ฃ์ด๋์ ์ผ๋ง ๋ณ๊ฒฝ๋ ์ฌํญ์ ํ๊ฒฝ์ผ๋ก ๊ฐ์ ธ์ค๊ธฐ ๋๋ฌธ์ ๋ฐ๋์ ์ํ์ ํ์๊ณ , ์งํํ์๋ฉด ๋ฉ๋๋ค.
๊ทธ๋ฌ๋ฉด ์ด๋ ๊ฒ Action ๋ณ๋ก ์คํ๋ ์ฌํญ์ ๋ณด์ฌ์ฃผ๊ฒ ๋ฉ๋๋ค. Travis CI๋ฅผ ์๋ง ๋น๋ ํ๊ฒฝ์ผ๋ก ์ฌ์ฉํ๊ณ ์๋ ๋ฏํ๊ณ , UI ๋ํ Travis CI์ ๋งค์ฐ ํก์ฌํ๊ฒ ์๊ฒจ์ ๋ณด๊ธฐ ํธํ ์ ๋ ์๋ค์..
Action์ ์ด๋ฆ์ ๋ฃ๋ ๊ธฐ๋ฅ์ ๊ต์ฅํ ์ ์ฉํด๋ณด์ ๋๋ค. ๊ฐ ํ ์คํธ์ ์ด๋ฆ์ ๋ถ์ฌํ์ฌ ์ฌ์ฉํ๋ค๋ฉด, ์ข ๋ ํ ์คํธ ๊ฒฐ๊ณผ๋ฅผ ํธํ๊ฒ ๋ณผ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
๋ค์ ๊ธ์์๋ Token ๋ฑ์ ๋ฏผ๊ฐํ ์ ๋ณด, ๋ธ๋์น ๋ณ ํ ์คํธ, ๋ฉํฐ OS ํ๊ฒฝ์์์ ํ ์คํธ ๋ฑ์ ์ดํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
'DevOps > Git' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Github] Github Actions์ Firebase Channel์ ์ด์ฉํ ์คํ ์ด์ง ํ๊ฒฝ ๊ตฌ์ถ (0) | 2021.08.29 |
---|---|
[Github] Password authentication was removed์ ๋์ฒํ๊ธฐ (0) | 2021.08.19 |
Github Actions - React ํ๋ก์ ํธ๋ฅผ Firebase์ Deploy ํ๊ธฐ (0) | 2019.08.27 |
Github Actions - Matrix & Secrets (0) | 2019.08.26 |
Github Actions ๋๋์ด ํ์ฑํ ๋๋ค. (0) | 2019.08.24 |