Github Action
- github에서 CI/CD 파이프라인을 자동화하는 툴.
- CI(Continuous Integreation: 지속적 통합)
- CD(Continuous Deployment: 지속적 배포)
- 코드 검증, 배포, 테스트, 빌드 등의 workflow를 자동화 할 수 있음.
.yaml, .yml 형식의 파일을 코드베이스의 .github/workflows 폴더에 생성
Github Pages
- Github에서 제공하는 static web hosting 서비스.
- github 레퍼지토리 기반으로 사이트를 생성하고 해당 사이트에 대한 도메인을 제공함.
- 커스텀 도메인 연결 가능
Github Pages 설정
- github 레퍼지토리 생성
- 레퍼지토리 이름은
username.github.io 의 형식
- HTML, CSS, JS 등의 파일을 추가하여 프로젝트를 생성.
- Pages 설정
- 해당 레퍼지토리의 Setting 탭 > Pages > Build and deployment의 Source
- 기본으로
Deploy from a branch 설정
- NextJS 등의 추가 프로젝트 관련 배포 설정이 필요한 경우 Github Actions를 설정
NextJS 프로젝트 배포 Github Action 예시
.gibhub/workflows/main.yaml 파일 등의 예시
name: Deploy Next.js to GitHub Pages
on:
push:
branches:
- main
workflow_dispatch:
schdule: ...
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
- name: Build static site
run: |
npm run build # Next.js 빌드
npm run export # 정적 파일 생성
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
output: "export",
};
export default nextConfig;