⚡ MarkSphere v1.0.16 #51
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: social-bookmarking/back | |
| 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: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # [추가] docker-compose.yml 파일을 서버로 전송 | |
| - name: Copy docker-compose.yml to OCI | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.OCI_HOST }} | |
| username: ${{ secrets.OCI_USERNAME }} | |
| key: ${{ secrets.OCI_KEY }} | |
| source: "docker-compose.yml" | |
| target: "~/marksphere-project" | |
| - name: Deploy to OCI via SSH | |
| 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.yml 파일 내의 이미지를 GHCR 이미지로 강제 지정 | |
| sed -i 's/build: ./image: ghcr.io\/social-bookmarking\/back:latest/' docker-compose.yml | |
| docker-compose pull | |
| docker-compose up -d --force-recreate | |
| docker image prune -f |