|
| 1 | +name: Dev CI/CD - Sequential Deploy Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - test/sequential-deploy # 테스트 브랜치에서만 실행 |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 10 | + cancel-in-progress: false |
| 11 | + |
| 12 | +env: |
| 13 | + REGISTRY: docker.io |
| 14 | + IMAGE_PREFIX: ninecraft0523/ninecraft |
| 15 | + |
| 16 | +jobs: |
| 17 | + detect-changes: |
| 18 | + runs-on: ubuntu-24.04 |
| 19 | + outputs: |
| 20 | + apis: ${{ steps.filter.outputs.apis }} |
| 21 | + batch: ${{ steps.filter.outputs.batch }} |
| 22 | + any: ${{ steps.filter.outputs.any }} |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Check changed files |
| 28 | + uses: dorny/paths-filter@v3 |
| 29 | + id: filter |
| 30 | + with: |
| 31 | + filters: | |
| 32 | + apis: |
| 33 | + - 'apis/**' |
| 34 | + - 'domain/**' |
| 35 | + - 'infra/**' |
| 36 | + - 'global-utils/**' |
| 37 | + - 'observability/**' |
| 38 | + - '.github/**' |
| 39 | + batch: |
| 40 | + - 'batch/**' |
| 41 | + - 'domain/**' |
| 42 | + - 'infra/**' |
| 43 | + - 'global-utils/**' |
| 44 | + - 'observability/**' |
| 45 | + - '.github/**' |
| 46 | + any: |
| 47 | + - 'apis/**' |
| 48 | + - 'batch/**' |
| 49 | + - 'domain/**' |
| 50 | + - 'infra/**' |
| 51 | + - 'global-utils/**' |
| 52 | + - 'observability/**' |
| 53 | + - '.github/**' |
| 54 | +
|
| 55 | + # ======================================== |
| 56 | + # 순차 배포: APIs 먼저 |
| 57 | + # ======================================== |
| 58 | + deploy-apis-sequential: |
| 59 | + needs: detect-changes |
| 60 | + if: needs.detect-changes.outputs.apis == 'true' |
| 61 | + runs-on: ubuntu-24.04 |
| 62 | + timeout-minutes: 20 |
| 63 | + environment: development |
| 64 | + steps: |
| 65 | + - name: Checkout code |
| 66 | + uses: actions/checkout@v4 |
| 67 | + |
| 68 | + - name: Deploy APIs module (Sequential) |
| 69 | + uses: ./.github/actions/deploy-module |
| 70 | + with: |
| 71 | + environment: dev |
| 72 | + module: apis |
| 73 | + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 74 | + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} |
| 75 | + secret-properties: ${{ secrets.DEV_SECRET_PROPERTIES }} |
| 76 | + apple-auth-key: ${{ secrets.APPLE_AUTH_KEY }} |
| 77 | + host: ${{ secrets.DEV_HOST }} |
| 78 | + username: ${{ secrets.DEV_USERNAME }} |
| 79 | + ssh-key: ${{ secrets.DEV_SSH_KEY }} |
| 80 | + ssh-port: ${{ secrets.DEV_PORT }} |
| 81 | + discord-webhook-url: ${{ secrets.DEV_DEPLOY_DISCORD_WEBHOOK_URL }} |
| 82 | + image-prefix: ${{ env.IMAGE_PREFIX }} |
| 83 | + image-tag-type: type=raw,value=development-latest |
| 84 | + deploy-script: deploy-dev.sh |
| 85 | + |
| 86 | + # ======================================== |
| 87 | + # 순차 배포: Batch는 APIs 완료 후 |
| 88 | + # ======================================== |
| 89 | + deploy-batch-sequential: |
| 90 | + needs: [detect-changes, deploy-apis-sequential] # ← 핵심: APIs 끝나야 시작! |
| 91 | + if: | |
| 92 | + always() && |
| 93 | + needs.detect-changes.outputs.batch == 'true' && |
| 94 | + (needs.deploy-apis-sequential.result == 'success' || needs.deploy-apis-sequential.result == 'skipped') |
| 95 | + runs-on: ubuntu-24.04 |
| 96 | + timeout-minutes: 20 |
| 97 | + environment: development |
| 98 | + steps: |
| 99 | + - name: Checkout code |
| 100 | + uses: actions/checkout@v4 |
| 101 | + |
| 102 | + - name: Deploy Batch module (Sequential - after APIs) |
| 103 | + uses: ./.github/actions/deploy-module |
| 104 | + with: |
| 105 | + environment: dev |
| 106 | + module: batch |
| 107 | + dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 108 | + dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} |
| 109 | + secret-properties: ${{ secrets.DEV_SECRET_PROPERTIES }} |
| 110 | + apple-auth-key: ${{ secrets.APPLE_AUTH_KEY }} |
| 111 | + host: ${{ secrets.DEV_HOST }} |
| 112 | + username: ${{ secrets.DEV_USERNAME }} |
| 113 | + ssh-key: ${{ secrets.DEV_SSH_KEY }} |
| 114 | + ssh-port: ${{ secrets.DEV_PORT }} |
| 115 | + discord-webhook-url: ${{ secrets.DEV_DEPLOY_DISCORD_WEBHOOK_URL }} |
| 116 | + image-prefix: ${{ env.IMAGE_PREFIX }} |
| 117 | + image-tag-type: type=raw,value=development-latest |
| 118 | + deploy-script: deploy-dev.sh |
0 commit comments