Skip to content

Commit 4c9800f

Browse files
committed
..
1 parent a352fe2 commit 4c9800f

File tree

1 file changed

+237
-45
lines changed

1 file changed

+237
-45
lines changed

.github/workflows/main.yml

+237-45
Original file line numberDiff line numberDiff line change
@@ -48,51 +48,243 @@ jobs:
4848
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
4949
run: snyk test --all-projects --severity-threshold=high --fail-on=all
5050

51-
deploy:
52-
needs: integration-tests
53-
runs-on: ubuntu-latest
54-
steps:
55-
- name: Checkout code
56-
uses: actions/checkout@v3
57-
58-
- name: Install Node.js
59-
uses: actions/setup-node@v2
60-
with:
61-
node-version: '16' # Usa Node.js 16 para evitar incompatibilidades
62-
63-
- name: Install dependencies
64-
run: npm install
65-
66-
- name: Install Expo EAS CLI
67-
run: npm install -g eas-cli
68-
69-
# Autenticación en Expo y EAS usando el token
70-
- name: Log in to Expo with EAS Token
71-
run: eas login --token ${{ secrets.EXPO_TOKEN }}
72-
73-
# Configurar EAS Update (se asegura de que el proyecto esté configurado correctamente)
74-
- name: Configure EAS Update
75-
run: eas update:configure
76-
env:
77-
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
78-
79-
# Publicar actualización de EAS (esto reemplaza `expo publish`)
80-
- name: Publish EAS Update
81-
run: eas update --non-interactive
82-
env:
83-
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
84-
85-
# Compilar la aplicación Android
86-
- name: EAS Build (Android)
87-
run: eas build --platform android --non-interactive
88-
env:
89-
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
90-
91-
# Compilar la aplicación iOS
92-
- name: EAS Build (iOS)
93-
run: eas build --platform ios --non-interactive
94-
env:
95-
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
51+
deploy:
52+
needs: integration-tests
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Checkout code
56+
uses: actions/checkout@v3
57+
58+
- name: Install Node.js
59+
uses: actions/setup-node@v2
60+
with:
61+
node-version: '16' # Usa Node.js 16 para evitar incompatibilidades
62+
63+
- name: Install dependencies
64+
run: npm install
65+
66+
- name: Install Expo EAS CLI
67+
run: npm install -g eas-cli
68+
69+
# Autenticación en Expo y EAS usando el token
70+
- name: Log in to Expo with EAS Token
71+
run: eas login --token ${{ secrets.EXPO_TOKEN }}
72+
73+
# Configurar EAS Update (se asegura de que el proyecto esté configurado correctamente)
74+
- name: Configure EAS Update
75+
run: eas update:configure
76+
env:
77+
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
78+
79+
# Publicar actualización de EAS (esto reemplaza `expo publish`)
80+
- name: Publish EAS Update
81+
run: eas update --non-interactive
82+
env:
83+
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
84+
85+
# Compilar la aplicación Android
86+
- name: EAS Build (Android)
87+
run: eas build --platform android --non-interactive
88+
env:
89+
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
90+
91+
# Compilar la aplicación iOS
92+
- name: EAS Build (iOS)
93+
run: eas build --platform ios --non-interactive
94+
env:
95+
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
96+
97+
notify-email:
98+
needs: [lint, integration-tests, deploy]
99+
runs-on: ubuntu-latest
100+
steps:
101+
- name: Prepare SHA and Run ID
102+
id: vars
103+
run: |
104+
echo "::set-output name=short_sha::${GITHUB_SHA::7}"
105+
echo "::set-output name=short_run_id::${GITHUB_RUN_ID::7}"
106+
107+
- name: Send Notification Email
108+
uses: dawidd6/action-send-mail@v3
109+
with:
110+
server_address: ${{ secrets.SMTP_HOST }}
111+
server_port: ${{ secrets.SMTP_PORT }}
112+
username: ${{ secrets.SMTP_USERNAME }}
113+
password: ${{ secrets.SMTP_PASSWORD }}
114+
subject: CI/CD Pipeline Notification - ${{ github.ref_name }}
115+
from: CI/CD Bot <ci-bot@example.com>
116+
to: ${{ secrets.EMAIL_TO }}
117+
html_body: |
118+
<html lang="es">
119+
<head>
120+
<meta charset="UTF-8">
121+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
122+
<title>Notificación de CI/CD Pipeline</title>
123+
<style>
124+
body {
125+
font-family: Arial, sans-serif;
126+
background-color: #f4f4f4;
127+
margin: 0;
128+
padding: 20px;
129+
}
130+
.container {
131+
max-width: 600px;
132+
margin: 0 auto;
133+
background-color: #fff;
134+
border-radius: 10px;
135+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
136+
overflow: hidden;
137+
}
138+
.header {
139+
background-color: #4CAF50;
140+
padding: 20px;
141+
color: white;
142+
text-align: center;
143+
}
144+
.content {
145+
padding: 20px;
146+
color: #333;
147+
}
148+
.content h3 {
149+
color: #4CAF50;
150+
}
151+
.content p {
152+
line-height: 1.5;
153+
margin-bottom: 20px;
154+
}
155+
.button {
156+
background-color: #4CAF50;
157+
color: white;
158+
padding: 10px 20px;
159+
text-align: center;
160+
border-radius: 5px;
161+
text-decoration: none;
162+
display: inline-block;
163+
margin-top: 20px;
164+
}
165+
.footer {
166+
text-align: center;
167+
font-size: 12px;
168+
color: #888;
169+
padding: 10px;
170+
border-top: 1px solid #eee;
171+
}
172+
</style>
173+
</head>
174+
<body>
175+
<div class="container">
176+
<div class="header">
177+
<h1>🚀 Notificación de CI/CD Pipeline</h1>
178+
</div>
179+
<div class="content">
180+
<h3>El pipeline ha finalizado</h3>
181+
<p>El estado del pipeline es: <strong>${{ job.status }}</strong></p>
182+
<p><strong>Rama:</strong> ${{ github.ref_name }}</p>
183+
<p><strong>Commit SHA:</strong> ${{ steps.vars.outputs.short_sha }}</p>
184+
<p><strong>ID de Ejecución:</strong> ${{ steps.vars.outputs.short_run_id }}</p>
185+
<a href="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" class="button">Ver resultados del pipeline</a>
186+
</div>
187+
<div class="footer">
188+
<p>Este es un mensaje automatizado de tu bot de CI/CD. No es necesario responder.</p>
189+
</div>
190+
</div>
191+
</body>
192+
</html>
193+
name: Movil CI/CD Workflow - Main
194+
195+
on:
196+
push:
197+
branches:
198+
- main
199+
pull_request:
200+
branches:
201+
- main
202+
203+
permissions: write-all
204+
205+
jobs:
206+
lint:
207+
runs-on: ubuntu-latest
208+
steps:
209+
- uses: actions/checkout@v3
210+
- name: Set up Node.js
211+
uses: actions/setup-node@v2
212+
with:
213+
node-version: '20'
214+
- name: Install dependencies
215+
run: npm install
216+
- name: Run ESLint
217+
run: npm run lint || echo "Lint errors encountered, but continuing."
218+
219+
integration-tests:
220+
needs: lint
221+
runs-on: ubuntu-latest
222+
steps:
223+
- uses: actions/checkout@v3
224+
- name: Install dependencies
225+
run: npm install
226+
- name: Check installed packages
227+
run: npm list jest
228+
- name: Run Integration Tests
229+
run: npm run test:integration
230+
231+
snyk-scan:
232+
needs: integration-tests
233+
runs-on: ubuntu-latest
234+
steps:
235+
- uses: actions/checkout@v3
236+
- name: Install Snyk CLI
237+
run: npm install -g snyk
238+
- name: Run Snyk Scan
239+
env:
240+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
241+
run: snyk test --all-projects --severity-threshold=high --fail-on=all
242+
243+
deploy:
244+
needs: integration-tests
245+
runs-on: ubuntu-latest
246+
steps:
247+
- name: Checkout code
248+
uses: actions/checkout@v3
249+
250+
- name: Install Node.js
251+
uses: actions/setup-node@v2
252+
with:
253+
node-version: '16' # Usa Node.js 16 para evitar incompatibilidades
254+
255+
- name: Install dependencies
256+
run: npm install
257+
258+
- name: Install Expo EAS CLI
259+
run: npm install -g eas-cli
260+
261+
# Autenticación en Expo y EAS usando el token
262+
- name: Log in to Expo with EAS Token
263+
run: eas login --token ${{ secrets.EXPO_TOKEN }}
264+
265+
# Configurar EAS Update (se asegura de que el proyecto esté configurado correctamente)
266+
- name: Configure EAS Update
267+
run: eas update:configure
268+
env:
269+
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
270+
271+
# Publicar actualización de EAS (esto reemplaza `expo publish`)
272+
- name: Publish EAS Update
273+
run: eas update --non-interactive
274+
env:
275+
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
276+
277+
# Compilar la aplicación Android
278+
- name: EAS Build (Android)
279+
run: eas build --platform android --non-interactive
280+
env:
281+
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
282+
283+
# Compilar la aplicación iOS
284+
- name: EAS Build (iOS)
285+
run: eas build --platform ios --non-interactive
286+
env:
287+
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
96288

97289
notify-email:
98290
needs: [lint, integration-tests, deploy]

0 commit comments

Comments
 (0)