diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa68a19..951bea9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,13 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: '22' - cache: 'npm' + - name: Setup Node.js + run: | + if ! command -v node &>/dev/null || [ "$(node -v | cut -d. -f1 | tr -d v)" -lt 22 ]; then + curl -fsSL https://deb.nodesource.com/setup_22.x | bash - + apt-get install -y nodejs + fi + node -v && npm -v - name: Install dependencies run: npm ci --legacy-peer-deps @@ -40,37 +43,28 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: docker/setup-buildx-action@v3 + - name: Login to Gitea Registry + run: echo "${{ secrets.GITEA_TOKEN }}" | docker login git.tolelom.xyz -u "${{ github.actor }}" --password-stdin - - uses: docker/login-action@v3 - with: - registry: git.tolelom.xyz - username: ${{ github.actor }} - password: ${{ secrets.GITEA_TOKEN }} - - - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: git.tolelom.xyz/${{ github.repository_owner }}/a301-web:latest - platforms: linux/arm64 - build-args: | - VITE_API_BASE_URL=https://a301.api.tolelom.xyz - cache-from: type=gha - cache-to: type=gha,mode=max + - name: Build and Push Docker Image + run: | + docker build \ + --build-arg VITE_API_BASE_URL=https://a301.api.tolelom.xyz \ + -t git.tolelom.xyz/${{ github.repository_owner }}/a301-web:latest \ + . + docker push git.tolelom.xyz/${{ github.repository_owner }}/a301-web:latest # ── 3. 서버 배포 ────────────────────────────────────────────────────────── deploy: needs: docker runs-on: ubuntu-latest steps: - - uses: appleboy/ssh-action@v1 - with: - host: ${{ secrets.SERVER_HOST }} - username: ${{ secrets.SERVER_USER }} - key: ${{ secrets.SSH_PRIVATE_KEY }} - script: | - export PATH=$PATH:/usr/local/bin:/opt/homebrew/bin:$HOME/.docker/bin - cd ~/server - docker compose pull web - docker compose up -d web + - name: Deploy to Server + run: | + mkdir -p ~/.ssh + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key + chmod 600 ~/.ssh/deploy_key + ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key \ + ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} \ + 'export PATH=$PATH:/usr/local/bin:/opt/homebrew/bin:$HOME/.docker/bin && cd ~/server && docker compose pull web && docker compose up -d web' + rm -f ~/.ssh/deploy_key