๐ป DEV/GitHub
[Github Actions] ํ๋ก์ ํธ์ github Actions ์ ์ฉ
Rising Oneโ
2025. 3. 10. 14:07
728x90
๋ฐ์ํ
SMALL

์ ๊ทผ (์์ฝ)
์ ๋ฌด์์ Web Service ๋ฐฐํฌ ๋ฐฉ์์ ๋ณํ(→ Github Actions)๋ฅผ ๋๋ชจํ๋ค.
์ด๋ฌํ ๋ณํ๋ฅผ ๊ฐ์ธ ํ๋ก์ ํธ์๋ ์ ์ฉํ๊ณ ์ Nextjs ํ๋ก์ ํธ + Github Action์ ์ ์ฉํ ์ํ์ ๊ธฐ๋กํ๋ค.
(๊ฐ ๋จ๊ณ๋ฅผ Step๋ณ๋ก ์์ฑํด๋ณธ๋ค.)
0. Create Project (Terminal) → ํ๋จ์ ๊ฒ์๊ธ ์ฒจ๋ถ
- ๊ฒฝ๋ก ์ด๋
- Project App ์์ฑ
- Open Project & Branch ๋ณ๊ฒฝ (main → master)
- 4. ์๊ฒฉ์ ์ฅ์ ์์ฑ(Web) & Push (๋ก์ปฌ → ์๊ฒฉ์ ์ฅ์)
1. Github Action ์ ์ฉ
- (Web) Actions > set up a workflow yourself
-
๋ฐฉ๋ฒ
1. Github Action ์ ์ฉ
1. (Web) Actions > set up a workflow yourself

2. root ๊ฒฝ๋ก์ ./github/workflows/OOO.yml ํ์ผ์์ฑ

3. ๊ธฐ๋ณธ Build code ์์ฑ
name: Test Build
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
build:
runs-on: ubuntu-latest
# ์ง์ ์๋ฒ ์ด์์ (์์ฒด ํธ์คํ
)
# runs-on: action-runner-dev-linux
steps:
# Repo ์ฒดํฌ์์
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# package manager๋ฅผ ์๋์ผ๋ก ๊ฐ์งํ๋ ๋จ๊ณ
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager" >&2
exit 1
fi
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
# cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Install dependencies
run: npm install
# ๋ง์ผ, ํ๋ก์ ํธ ๊ฒฝ๋ก Depth๊ฐ ํ ์ธต ๋ ๋ค์ด๊ฐ๋ค๋ฉด, ์๋์ฒ๋ผ
# Detect package manager์ -f package.json ์ฐพ๋ ๊ฒฝ๋ก ๋ํ {{.}}/visualization/package.json
# working-directory: ./visualization
- name: Run ESLint
run: npm run lint
# TODO : Jest Test ์ฝ๋ ์ถ๊ฐ
# - name: Run Tests
# run: npm test
- name: Build Next.js
run: npm run build
action/checkout@v4 ์์ ํ๋ฒ์
4. ๋ก์ปฌ์ ์ฅ์ master ๋ธ๋์น์์ ์๊ฒฉ ์ ์ฅ์ pull
[ ์ฐธ๊ณ ]
[Github] ํ๋ก์ ํธ ์์ฑ (๋ก์ปฌ ์ ์ฅ์์์ ์๊ฒฉ ์ ์ฅ์ Push)
728x90
๋ฐ์ํ
LIST