diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..21f6ced --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,60 @@ +name: Deploy to Render + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 # Cambia la versione se necessario + + # Installazione dipendenze backend + - name: Install backend dependencies + run: | + cd backend + npm install + + # Esegui i test + - name: Run backend tests + run: | + cd backend + npm test + + # Se i test passano, installiamo dipendenze frontend + - name: Install frontend dependencies + run: | + cd frontend + npm install + + # Build del frontend + - name: Build frontend + run: | + cd frontend + npm run build + + # Deploy frontend su Render + - name: Deploy frontend to Render + if: success() # Esegue il deploy solo se i test passano + run: curl -X POST "$RENDER_DEPLOY_HOOK_FRONTEND" + env: + RENDER_DEPLOY_HOOK_FRONTEND: ${{ secrets.RENDER_DEPLOY_HOOK_FRONTEND }} + + # Deploy backend su Render + - name: Deploy backend to Render + if: success() # Esegue il deploy solo se i test passano + run: curl -X POST "$RENDER_DEPLOY_HOOK_BACKEND" + env: + RENDER_DEPLOY_HOOK_BACKEND: ${{ secrets.RENDER_DEPLOY_HOOK_BACKEND }}