⚡ MarkSphere v1.0.16 #49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: MarkSphere CI/CD (ARM64) | |
| on: | |
| push: | |
| branches: [ "main" ] # 메인 브랜치에 푸시될 때 실행 | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # 1. ARM64 빌드를 위한 에뮬레이터 설정 (핵심!) | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| # 2. Docker Buildx 설정 (멀티 플랫폼 빌드 도구) | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # 3. GitHub Container Registry 로그인 | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GHCR_TOKEN }} | |
| # 4. 이미지 빌드 및 푸시 (ARM64 전용) | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/arm64 # OCI Ampere A1 아키텍처에 맞춤 | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| deploy: | |
| needs: build-and-push | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 5. OCI 서버에 SSH로 접속하여 배포 명령 전달 | |
| - name: Deploy to OCI | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.OCI_HOST }} | |
| username: ${{ secrets.OCI_USERNAME }} | |
| key: ${{ secrets.OCI_KEY }} | |
| script: | | |
| cd ~/marksphere-project # 프로젝트 폴더 경로로 이동 | |
| # 새 이미지 가져오기 | |
| docker-compose pull | |
| # 컨테이너 재시작 (변경사항 반영) | |
| docker-compose up -d --force-recreate | |
| # 사용하지 않는 오래된 이미지 정리 (용량 관리) | |
| docker image prune -f |