-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (56 loc) · 1.54 KB
/
ci-cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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 }}
JWT_EXPIRATION: '6h'
DB_PORT: 5432
NODE_ENV: development
PORT: 3000
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 }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
JWT_EXPIRATION: '6h'
DB_PORT: 5432
NODE_ENV: production
PORT: 3000
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 }}