Update ci-cd.yml #4
This file contains 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: CI/CD Pipeline for Render | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
env: | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
steps: | |
# 1. Checkout del código | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# 2. Configurar Node.js | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '14' # Cambia a la versión que estás usando | |
# 3. Instalar dependencias | |
- name: Install dependencies | |
run: npm install | |
# 4. Ejecutar pruebas | |
- name: Run tests | |
run: npm test | |
deploy: | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' && success() | |
env: | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} # Asegúrate de pasar las variables aquí también | |
JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
steps: | |
# 1. Checkout del código | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# 2. Instalar CLI de Render | |
- name: Install Render CLI | |
run: | | |
curl -fsSL https://cli.render.com/install.sh | sudo bash | |
# 3. Desplegar en Render | |
- name: Deploy to Render | |
run: | | |
render deploy --service ${{ secrets.RENDER_SERVICE_ID }} --api-key ${{ secrets.RENDER_API_KEY }} |