macOS GitHub CLI 완전 자동화 시리즈 - 5편: 고급 워크플로우와 실무 적용
⏱️ 예상 읽기 시간: 25분
시리즈 완결편 소개
macOS GitHub CLI 완전 자동화 시리즈의 최종편입니다. 지금까지 구축한 모든 시스템을 통합하고, 실무에서 바로 활용할 수 있는 완성형 워크플로우를 만들어보겠습니다. CI/CD 연동, 팀 온보딩 자동화, 성능 최적화까지 다룹니다.
통합 시스템 아키텍처
1. 마스터 제어 시스템
# 마스터 제어 스크립트
cat > ~/scripts/github-cli/core/master-controller.sh << 'EOF'
#!/bin/bash
# GitHub CLI 마스터 제어 시스템
export GITHUB_CLI_VERSION="2.0"
export MASTER_CONFIG_DIR="$HOME/scripts/github-cli/config"
export MASTER_LOG_DIR="$HOME/Documents/github-automation/logs"
# 시스템 상태 확인
function gh_system_status() {
echo "🚀 GitHub CLI 자동화 시스템 상태"
echo "=================================="
echo
# 기본 환경 확인
echo "📋 환경 정보:"
echo " GitHub CLI: $(gh --version | head -1)"
echo " 현재 계정: $(gh api user -q .login 2>/dev/null || echo '미인증')"
echo " 컨텍스트: $(cat ~/.config/gh/current_context 2>/dev/null || echo '미설정')"
echo " 워크스페이스: $(current_workspace)"
echo
# 스크립트 시스템 상태
echo "🔧 스크립트 시스템:"
local script_dirs=("core" "wiki" "utils")
for dir in "${script_dirs[@]}"; do
if [[ -d "$HOME/scripts/github-cli/$dir" ]]; then
local file_count=$(find "$HOME/scripts/github-cli/$dir" -name "*.sh" | wc -l)
echo " $dir: ✅ ($file_count개 스크립트)"
else
echo " $dir: ❌ 누락"
fi
done
echo
# 활성 프로젝트
echo "📊 활성 프로젝트:"
gh project list --owner @me --limit 3 --format json | \
jq -r '.[] | " \(.title): \(.url)"' 2>/dev/null || echo " 없음"
echo
# 최근 활동
echo "📈 최근 활동 (7일):"
local recent_issues=$(gh issue list --author @me --search "created:>=$(date -d '-7 days' '+%Y-%m-%d')" --json number | jq length)
local recent_prs=$(gh pr list --author @me --search "created:>=$(date -d '-7 days' '+%Y-%m-%d')" --json number | jq length)
echo " 생성한 이슈: $recent_issues개"
echo " 생성한 PR: $recent_prs개"
}
# 시스템 자가 진단
function gh_system_doctor() {
echo "🏥 GitHub CLI 시스템 진단"
echo "========================"
echo
local issues=0
# 필수 도구 확인
local required_tools=("gh" "git" "jq" "curl")
for tool in "${required_tools[@]}"; do
if command -v "$tool" >/dev/null 2>&1; then
echo "✅ $tool 설치됨"
else
echo "❌ $tool 미설치"
issues=$((issues + 1))
fi
done
echo
# 인증 상태 확인
if gh auth status >/dev/null 2>&1; then
echo "✅ GitHub CLI 인증 완료"
else
echo "❌ GitHub CLI 인증 필요"
issues=$((issues + 1))
fi
# 스크립트 권한 확인
if [[ -x "$HOME/scripts/github-cli/core/master-controller.sh" ]]; then
echo "✅ 스크립트 실행 권한 확인"
else
echo "❌ 스크립트 실행 권한 없음"
issues=$((issues + 1))
fi
# 설정 파일 확인
if [[ -f "$HOME/.config/gh/current_context" ]]; then
echo "✅ 컨텍스트 설정 확인"
else
echo "⚠️ 컨텍스트 미설정 (권장사항)"
fi
echo
if [[ $issues -eq 0 ]]; then
echo "🎉 시스템이 정상적으로 작동합니다!"
else
echo "⚠️ $issues개의 문제가 발견되었습니다."
echo "💡 'gh_system_repair' 명령어로 자동 복구를 시도하세요."
fi
}
# 시스템 자동 복구
function gh_system_repair() {
echo "🔧 시스템 자동 복구 시작..."
# 스크립트 권한 복구
find "$HOME/scripts/github-cli" -name "*.sh" -exec chmod +x {} \;
echo "✅ 스크립트 실행 권한 복구"
# 디렉토리 구조 복구
mkdir -p "$HOME/scripts/github-cli"/{core,wiki,utils,config}
mkdir -p "$HOME/Documents/github-automation/logs"
echo "✅ 디렉토리 구조 복구"
# 로그 정리
find "$MASTER_LOG_DIR" -name "*.log" -mtime +30 -delete 2>/dev/null
echo "✅ 오래된 로그 정리"
echo "🎉 시스템 복구 완료!"
}
EOF
chmod +x ~/scripts/github-cli/core/master-controller.sh
2. CI/CD 파이프라인 연동
# GitHub Actions 연동 시스템
cat > ~/scripts/github-cli/core/cicd-integration.sh << 'EOF'
#!/bin/bash
# CI/CD 파이프라인 자동 생성
function create_cicd_workflow() {
local project_type="${1:-general}"
local workflow_dir=".github/workflows"
mkdir -p "$workflow_dir"
case "$project_type" in
"node"|"javascript"|"typescript")
create_node_workflow "$workflow_dir"
;;
"python")
create_python_workflow "$workflow_dir"
;;
"go")
create_go_workflow "$workflow_dir"
;;
*)
create_general_workflow "$workflow_dir"
;;
esac
# GitHub CLI 자동화 연동
create_automation_workflow "$workflow_dir"
echo "✅ CI/CD 워크플로우가 생성되었습니다."
}
# Node.js 워크플로우
function create_node_workflow() {
local workflow_dir="$1"
cat > "$workflow_dir/ci.yml" << 'NODEEOF'
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: $
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Run linting
run: npm run lint
- name: Update Wiki
if: github.ref == 'refs/heads/main'
run: |
# 위키 자동 업데이트 (GitHub CLI 사용)
npm run docs:generate || true
gh extension install github/gh-wiki || true
gh wiki sync || true
env:
GITHUB_TOKEN: $
NODEEOF
}
# 자동화 연동 워크플로우
function create_automation_workflow() {
local workflow_dir="$1"
cat > "$workflow_dir/automation.yml" << 'AUTOEOF'
name: GitHub CLI Automation
on:
issues:
types: [opened, closed, labeled]
pull_request:
types: [opened, closed, merged]
schedule:
- cron: '0 9 * * *' # 매일 오전 9시
jobs:
automation:
runs-on: ubuntu-latest
steps:
- name: Auto-assign issues
if: github.event_name == 'issues' && github.event.action == 'opened'
run: |
# 이슈 자동 할당 및 프로젝트 추가
gh issue edit $ --add-assignee "@team"
gh project item-add $ --url $
env:
GITHUB_TOKEN: $
- name: Update project status
if: github.event_name == 'pull_request' && github.event.action == 'opened'
run: |
# PR 생성 시 관련 이슈 상태 업데이트
gh pr view $ --json body | \
jq -r '.body' | grep -o '#[0-9]\+' | \
xargs -I {} gh issue edit {} --add-label "in-review"
env:
GITHUB_TOKEN: $
- name: Daily report
if: github.event_name == 'schedule'
run: |
# 일일 보고서 생성 및 알림
gh issue create --title "Daily Report $(date +%Y-%m-%d)" \
--body "자동 생성된 일일 활동 보고서" \
--label "report,automated"
env:
GITHUB_TOKEN: $
AUTOEOF
}
# 배포 모니터링
function monitor_deployment() {
local workflow_name="$1"
local max_wait="${2:-300}" # 5분
echo "🔍 배포 모니터링 시작: $workflow_name"
local start_time=$(date +%s)
while true; do
local status=$(gh run list --workflow="$workflow_name" --limit=1 --json status -q '.[0].status')
local current_time=$(date +%s)
local elapsed=$((current_time - start_time))
case "$status" in
"completed")
local conclusion=$(gh run list --workflow="$workflow_name" --limit=1 --json conclusion -q '.[0].conclusion')
if [[ "$conclusion" == "success" ]]; then
echo "✅ 배포 성공! ($elapsed초 소요)"
else
echo "❌ 배포 실패: $conclusion"
gh run view --log-failed
fi
break
;;
"in_progress")
echo "🔄 배포 진행 중... ($elapsed초 경과)"
;;
"queued")
echo "⏳ 배포 대기 중... ($elapsed초 경과)"
;;
esac
if [[ $elapsed -gt $max_wait ]]; then
echo "⏰ 모니터링 시간 초과 ($max_wait초)"
break
fi
sleep 10
done
}
EOF
chmod +x ~/scripts/github-cli/core/cicd-integration.sh
3. 팀 온보딩 자동화
# 팀 온보딩 시스템
cat > ~/scripts/github-cli/core/team-onboarding.sh << 'EOF'
#!/bin/bash
# 신규 팀원 온보딩
function onboard_team_member() {
local username="$1"
local role="${2:-developer}"
local team="${3:-dev-team}"
if [[ -z "$username" ]]; then
echo "사용법: onboard_team_member <GitHub사용자명> [역할] [팀]"
return 1
fi
echo "👋 신규 팀원 온보딩: @$username"
echo "================================="
# 1. 저장소 접근 권한 부여
echo "🔑 저장소 권한 설정 중..."
local repos=$(gh repo list --limit 100 --json name -q '.[].name')
while IFS= read -r repo; do
gh api "repos/:owner/$repo/collaborators/$username" \
-X PUT -f permission="push" 2>/dev/null && \
echo " ✅ $repo 접근 권한 부여"
done <<< "$repos"
# 2. 팀에 추가
echo "👥 팀 추가 중..."
gh api "orgs/:owner/teams/$team/memberships/$username" \
-X PUT -f role="member" 2>/dev/null && \
echo " ✅ $team 팀에 추가됨"
# 3. 온보딩 이슈 생성
echo "📝 온보딩 체크리스트 생성 중..."
local onboarding_issue=$(gh issue create \
--title "🎉 @$username 님 온보딩 체크리스트" \
--body "# 신규 팀원 온보딩 체크리스트
안녕하세요 @$username 님! 팀에 합류하신 것을 환영합니다 🎉
## 📋 온보딩 체크리스트
### 계정 설정
- [ ] GitHub 2FA 활성화
- [ ] 프로필 사진 및 정보 업데이트
- [ ] SSH 키 등록
### 개발 환경 설정
- [ ] GitHub CLI 설치 및 설정
- [ ] 자동화 스크립트 설정
- [ ] IDE/에디터 설정
### 프로젝트 이해
- [ ] 위키 문서 읽기
- [ ] 코드베이스 리뷰
- [ ] 아키텍처 문서 이해
### 첫 번째 기여
- [ ] Good First Issue 완료
- [ ] 첫 번째 PR 생성
- [ ] 코드 리뷰 참여
### 팀 소개
- [ ] 팀 미팅 참석
- [ ] 멘토와 1:1 미팅
- [ ] 팀 채널 가입
## 🆘 도움이 필요하시면
- 기술적 문제: @tech-leads
- 프로세스 관련: @team-leads
- 일반 문의: @$team
---
할당자: @$username
담당팀: $team" \
--assignee "$username" \
--label "onboarding,$team" \
--format json | jq -r '.number')
echo "✅ 온보딩 이슈 #$onboarding_issue 생성됨"
# 4. 환영 메시지
gh issue comment "$onboarding_issue" --body "🎊 @$username 님을 $team 팀의 $role로 환영합니다!
위의 체크리스트를 완료하시면서 팀에 적응해보세요.
질문이 있으시면 언제든 멘션해주세요! 🚀"
echo "🎉 온보딩 프로세스가 완료되었습니다!"
}
# 프로젝트 설정 가이드 생성
function create_project_setup_guide() {
local project_name="$1"
if [[ -z "$project_name" ]]; then
echo "사용법: create_project_setup_guide <프로젝트명>"
return 1
fi
echo "📚 프로젝트 설정 가이드 생성 중..."
# 설정 가이드 이슈 생성
gh issue create \
--title "📚 $project_name 프로젝트 설정 가이드" \
--body "# $project_name 프로젝트 설정 가이드
## 🚀 빠른 시작
### 1. 저장소 클론
\`\`\`bash
git clone $(gh repo view --json cloneUrl -q .cloneUrl)
cd $project_name
\`\`\`
### 2. 의존성 설치
\`\`\`bash
# 프로젝트 타입에 따라 자동 감지
~/scripts/github-cli/utils/auto-setup.sh
\`\`\`
### 3. 개발 환경 설정
\`\`\`bash
# GitHub CLI 자동화 설정
gh extension install github/gh-cli-automation
\`\`\`
## 🔧 개발 워크플로우
### 이슈 기반 개발
1. \`gh issue create\` - 새 이슈 생성
2. \`issue_start <번호>\` - 작업 시작
3. \`issue_finish <번호>\` - 작업 완료
### 코드 리뷰
1. \`gh pr create\` - PR 생성
2. \`auto_assign_reviewers <PR번호>\` - 리뷰어 자동 할당
3. \`gh pr merge\` - 병합
## 📖 추가 자료
- [API 문서](../../wiki/API-Documentation)
- [코딩 컨벤션](../../wiki/Coding-Conventions)
- [배포 가이드](../../wiki/Deployment-Guide)
---
*이 가이드는 자동으로 생성되었습니다.*" \
--label "documentation,guide" \
--pin
echo "✅ 프로젝트 설정 가이드가 생성되었습니다."
}
# 팀 성과 리포트
function generate_team_report() {
local team_name="${1:-dev-team}"
local period="${2:-30}"
echo "📊 $team_name 팀 성과 리포트 (최근 ${period}일)"
echo "============================================="
echo
# 팀 멤버 활동
echo "👥 팀 멤버 기여도:"
gh api "search/issues?q=author:@$team_name+type:pr+closed:>$(date -d "-$period days" +%Y-%m-%d)" | \
jq -r '.items[] | .user.login' | sort | uniq -c | sort -nr | \
while read count member; do
echo " $member: $count개 PR"
done
echo
# 이슈 처리 현황
echo "📋 이슈 처리 현황:"
local created=$(gh issue list --search "team:$team_name created:>$(date -d "-$period days" +%Y-%m-%d)" --json number | jq length)
local closed=$(gh issue list --search "team:$team_name closed:>$(date -d "-$period days" +%Y-%m-%d)" --json number | jq length)
echo " 생성: $created개"
echo " 완료: $closed개"
echo " 처리율: $(( closed * 100 / created ))%"
echo
# 코드 리뷰 통계
echo "👀 코드 리뷰 통계:"
local reviewed=$(gh api "search/issues?q=reviewed-by:@$team_name+type:pr+updated:>$(date -d "-$period days" +%Y-%m-%d)" | jq '.total_count')
echo " 리뷰한 PR: $reviewed개"
echo
echo "💡 개선 제안:"
if [[ $closed -lt $created ]]; then
echo " - 이슈 처리 속도 향상 필요"
fi
if [[ $reviewed -lt 10 ]]; then
echo " - 코드 리뷰 참여도 증진 필요"
fi
}
EOF
chmod +x ~/scripts/github-cli/core/team-onboarding.sh
4. 최종 zshrc 통합
# 최종 통합 zshrc 설정
cat >> ~/.zshrc << 'EOF'
# ===============================================
# GitHub CLI 완전 자동화 시스템 - 최종 통합
# ===============================================
# 모든 스크립트 모듈 로드
if [[ -d "$HOME/scripts/github-cli" ]]; then
# 설정 로드
source "$HOME/scripts/github-cli/config/wiki-config.sh" 2>/dev/null
# 핵심 시스템
source "$HOME/scripts/github-cli/core/master-controller.sh"
source "$HOME/scripts/github-cli/core/cicd-integration.sh"
source "$HOME/scripts/github-cli/core/team-onboarding.sh"
# 위키 시스템 (4편에서 구축)
for script in "$HOME/scripts/github-cli/wiki"/*.sh; do
[[ -f "$script" ]] && source "$script"
done
echo "🚀 GitHub CLI 완전 자동화 시스템 (v2.0) 로드 완료!"
fi
# 통합 명령어 시스템
function gh() {
local command="$1"
shift
case "$command" in
# 시스템 관리
"status") gh_system_status "$@" ;;
"doctor") gh_system_doctor "$@" ;;
"repair") gh_system_repair "$@" ;;
# 팀 관리
"onboard") onboard_team_member "$@" ;;
"team-report") generate_team_report "$@" ;;
# CI/CD
"create-workflow") create_cicd_workflow "$@" ;;
"monitor") monitor_deployment "$@" ;;
# 위키 (4편 기능)
"wiki") wiki "$@" ;;
# 기본 GitHub CLI
*) command gh "$command" "$@" ;;
esac
}
# 마스터 대시보드
function github_dashboard() {
clear
echo "
╔══════════════════════════════════════════════════════╗
║ GitHub CLI 자동화 대시보드 ║
╚══════════════════════════════════════════════════════╝
"
# 시스템 상태
gh_system_status
echo
# 오늘의 할 일
echo "📅 오늘의 할 일:"
gh issue list --assignee @me --state open --limit 3 --json number,title | \
jq -r '.[] | " • #\(.number): \(.title)"' 2>/dev/null || echo " 할 일이 없습니다 🎉"
echo
# 빠른 명령어
echo "🚀 빠른 명령어:"
echo " gh status - 시스템 상태 확인"
echo " gh doctor - 시스템 진단"
echo " gh wiki update - 위키 업데이트"
echo " issue_start <번호> - 이슈 작업 시작"
echo " github_dashboard - 이 대시보드"
}
# 시작 시 웰컴 메시지
function github_welcome() {
local current_hour=$(date +%H)
local greeting
if [[ $current_hour -lt 12 ]]; then
greeting="좋은 아침입니다"
elif [[ $current_hour -lt 18 ]]; then
greeting="좋은 오후입니다"
else
greeting="수고하셨습니다"
fi
echo "👋 $greeting! GitHub CLI 자동화 시스템이 준비되었습니다."
echo "💡 'github_dashboard' 명령어로 대시보드를 확인하세요."
}
# 시작 시 실행
github_welcome
# 단축키 설정
alias ghs="gh status"
alias ghd="gh doctor"
alias ghdash="github_dashboard"
EOF
source ~/.zshrc
5. 실무 적용 가이드
# 실무 적용 체크리스트 생성
cat > ~/scripts/github-cli/utils/deployment-checklist.sh << 'EOF'
#!/bin/bash
# 실무 배포 체크리스트
function create_deployment_checklist() {
echo "📋 GitHub CLI 자동화 시스템 배포 체크리스트"
echo "============================================="
echo
local checks=(
"GitHub CLI 설치 및 인증"
"스크립트 디렉토리 구조 생성"
"권한 설정 완료"
"회사/개인 계정 분리 설정"
"팀 멤버 온보딩 프로세스 구축"
"CI/CD 파이프라인 연동"
"위키 자동화 설정"
"모니터링 및 알림 설정"
)
for i in "${!checks[@]}"; do
echo "$((i+1)). [ ] ${checks[$i]}"
done
echo
echo "🎯 배포 후 확인사항:"
echo "- 'gh doctor' 명령어로 시스템 상태 확인"
echo "- 팀원들에게 사용법 교육"
echo "- 정기적인 업데이트 계획 수립"
}
# 성능 최적화 도구
function optimize_performance() {
echo "⚡ GitHub CLI 성능 최적화 실행 중..."
# 캐시 정리
rm -rf "$HOME/.cache/github-cli" 2>/dev/null
mkdir -p "$HOME/.cache/github-cli"
# 로그 정리
find "$HOME/Documents/github-automation/logs" -name "*.log" -mtime +7 -delete 2>/dev/null
# Git 설정 최적화
git config --global core.preloadindex true
git config --global core.fscache true
git config --global gc.auto 256
echo "✅ 성능 최적화 완료!"
}
# 백업 시스템
function backup_configuration() {
local backup_dir="$HOME/Documents/github-automation/backups/$(date +%Y%m%d_%H%M%S)"
mkdir -p "$backup_dir"
echo "💾 설정 백업 중..."
# 스크립트 백업
cp -r "$HOME/scripts/github-cli" "$backup_dir/"
# 설정 파일 백업
cp -r "$HOME/.config/gh" "$backup_dir/" 2>/dev/null || true
# zshrc 관련 설정 백업
grep -A 1000 "GitHub CLI 완전 자동화" ~/.zshrc > "$backup_dir/zshrc_github_section.txt"
echo "✅ 백업 완료: $backup_dir"
echo "📁 백업 내용:"
ls -la "$backup_dir"
}
create_deployment_checklist
EOF
chmod +x ~/scripts/github-cli/utils/deployment-checklist.sh
시리즈 완결
축하합니다! 🎉 GitHub CLI 완전 자동화 시리즈가 완성되었습니다.
🚀 구축된 시스템 요약
- 완전 자동화 환경 (1편)
- 다중 계정 관리
- 지능형 zshrc 설정
- 컨텍스트 기반 워크스페이스
- 이슈 관리 자동화 (2편)
- AI 기반 이슈 분류
- 스프린트 계획 자동화
- 워크플로우 상태 관리
- 프로젝트 관리 분리 (3편)
- GitHub Projects v2 자동화
- 팀 협업 시스템
- 회사/개인 프로젝트 완전 분리
- 위키 관리 자동화 (4편)
- 코드 기반 문서 생성
- 다국어 지원
- API 문서 자동 동기화
- 통합 시스템 구축 (5편)
- CI/CD 파이프라인 연동
- 팀 온보딩 자동화
- 성능 최적화 및 모니터링
💡 실무 활용 팁
github_dashboard
: 매일 아침 현황 확인gh doctor
: 주기적 시스템 점검gh onboard <사용자>
: 신규 팀원 온보딩wiki update
: 문서 자동 동기화gh team-report
: 팀 성과 분석
이제 여러분은 전문가급 GitHub 자동화 시스템을 완전히 구축했습니다! 🌟
이 시리즈의 다른 글 보기
- 1편: 설치와 환경 구성
- 2편: 이슈 관리 완전 자동화
- 3편: 프로젝트 관리 + 회사/개인 프로젝트 분리
- 4편: 위키 관리 완전 자동화
- 5편: 고급 워크플로우와 실무 적용 ← 완결편!