name: update_qa
on:
workflow_dispatch:
inputs:
branch:
description: "빌드 및 배포할 브랜치명"
required: true
default: "main"
jobs:
update-qa:
runs-on: ubuntu-latest
steps:
# Git 체크아웃
- name: Check out the repo
uses: actions/checkout@v2
with:
fetch-depth: 0 # 전체 히스토리 가져오기 (브랜치 작업/병합 위해 필요)
# Node 18 버전 세팅
- name: Setup Node 18
uses: actions/setup-node@v3
with:
node-version: 18
# 해당 브랜치로 체크아웃 후 main 병합
- name: Git merge main branch
run: |
git checkout ${{ github.event.inputs.branch }}
git fetch origin main
git merge origin/main -m "merge master"
git push
# 모듈 설치
- name: Install dependencies
run: npm install
# 빌드
- name: Build
run: CI=false npm run build
# SSH 에이전트 시작 → 개인 키 등록
- name: Set up SSH
uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: ${{ secrets.QA_SSH_PRIVATE_KEY }}
# rsync로 배포
- name: Deploy via rsync
run: |
rsync -avz --delete \
-e "ssh -o StrictHostKeyChecking=no -p ${{ secrets.QA_SSH_PORT }}" \
./build \
${{ secrets.QA_SSH_USER }}@${{ secrets.QA_SERVER_HOST }}:${{ secrets.QA_TARGET_PATH }}
secrets관련 설정은 github 해당 repo의
settings > Secrets and variables > Actions > Repository secrets에서 추가/수정
actions에 write권한이 없으면 git push명령어에서 오류 발생하게 됩니다.
해당 repo의 settings에서 권한 수정 필요