name: Deploy n8ngo Landing Page on: push: branches: [ main ] jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Cache Docker layers uses: actions/cache@v3 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- - name: Build and push Docker image uses: docker/build-push-action@v4 with: context: . file: ./Dockerfile platforms: linux/arm64 push: true tags: | registry.redecarneir.us/n8ngo-landing:latest registry.redecarneir.us/n8ngo-landing:${{ github.sha }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max build-args: BUILDKIT_INLINE_CACHE=1 - name: Move cache run: | rm -rf /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: Deploy to Production uses: appleboy/ssh-action@v1.0.3 with: host: 129.146.116.218 username: ${{ secrets.SSH_USERNAME }} key: ${{ secrets.SSH_PRIVATE_KEY }} port: 22 timeout: 60s script: | docker stop n8ngo-landing || true docker rm n8ngo-landing || true docker rmi registry.redecarneir.us/n8ngo-landing:latest || true docker pull registry.redecarneir.us/n8ngo-landing:latest docker run -d \ --name n8ngo-landing \ --restart unless-stopped \ --network host \ --memory=256m \ --cpus=0.5 \ -e NGINX_PORT=8070 \ registry.redecarneir.us/n8ngo-landing:latest docker image prune -f sleep 5 curl -f http://localhost:8070 || echo "Container ainda inicializando..." - name: Verify deployment uses: appleboy/ssh-action@v1.0.3 with: host: 129.146.116.218 username: ${{ secrets.SSH_USERNAME }} key: ${{ secrets.SSH_PRIVATE_KEY }} port: 22 script: | echo "=== Status ===" docker ps | grep n8ngo-landing echo "=== Ăšltimos logs ===" docker logs n8ngo-landing --tail 10