-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (152 loc) · 5.09 KB
/
main.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Movil CI/CD Workflow - Main
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions: write-all
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Run ESLint
run: npm run lint || echo "Lint errors encountered, but continuing."
integration-tests:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: npm install
- name: Check installed packages
run: npm list jest
- name: Run Integration Tests
run: npm run test:integration
snyk-scan:
needs: integration-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Snyk CLI
run: npm install -g snyk
- name: Run Snyk Scan
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
run: snyk test --all-projects --severity-threshold=high --fail-on=all
deploy:
needs: integration-tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '16' # Usa Node.js 16 para evitar incompatibilidades
- name: Install dependencies
run: npm instal
notify-email:
needs: [lint, integration-tests, deploy]
runs-on: ubuntu-latest
steps:
- name: Prepare SHA and Run ID
id: vars
run: |
echo "::set-output name=short_sha::${GITHUB_SHA::7}"
echo "::set-output name=short_run_id::${GITHUB_RUN_ID::7}"
- name: Send Notification Email
uses: dawidd6/action-send-mail@v3
with:
server_address: ${{ secrets.SMTP_HOST }}
server_port: ${{ secrets.SMTP_PORT }}
username: ${{ secrets.SMTP_USERNAME }}
password: ${{ secrets.SMTP_PASSWORD }}
subject: CI/CD Pipeline Notification - ${{ github.ref_name }}
from: CI/CD Bot <ci-bot@example.com>
to: ${{ secrets.EMAIL_TO }}
secure: false
html_body: |
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Notificación de CI/CD Pipeline</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
}
.container {
max-width: 600px;
margin: 0 auto;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.header {
background-color: #4CAF50;
padding: 20px;
color: white;
text-align: center;
}
.content {
padding: 20px;
color: #333;
}
.content h3 {
color: #4CAF50;
}
.content p {
line-height: 1.5;
margin-bottom: 20px;
}
.button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
text-align: center;
border-radius: 5px;
text-decoration: none;
display: inline-block;
margin-top: 20px;
}
.footer {
text-align: center;
font-size: 12px;
color: #888;
padding: 10px;
border-top: 1px solid #eee;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🚀 Notificación de CI/CD Pipeline</h1>
</div>
<div class="content">
<h3>El pipeline ha finalizado</h3>
<p>El estado del pipeline es: <strong>${{ job.status }}</strong></p>
<p><strong>Rama:</strong> ${{ github.ref_name }}</p>
<p><strong>Commit SHA:</strong> ${{ steps.vars.outputs.short_sha }}</p>
<p><strong>ID de Ejecución:</strong> ${{ steps.vars.outputs.short_run_id }}</p>
<a href="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" class="button">Ver resultados del pipeline</a>
</div>
<div class="footer">
<p>Este es un mensaje automatizado de tu bot de CI/CD. No es necesario responder.</p>
</div>
</div>
</body>
</html>