1+ # Nombre del flujo de trabajo
12name : Deploy app on EKS
3+ # Eventos que activan el workflow
24on :
35 push :
46 branches : [main]
57 pull_request :
68 branches : [main]
79 workflow_dispatch :
8-
10+ # Permisos requeridos para el workflow
911permissions :
1012 id-token : write
1113 contents : write
1214 packages : write
13-
15+ # Jobs del flujo del workflow
1416jobs :
15-
17+ # Prepara el caché y las dependencias
1618 Setup-Cache-Dependencies :
1719 runs-on : ubuntu-latest
1820 steps :
1921 - name : Checkout code
2022 uses : actions/checkout@v3
21-
23+ # Configuración de Node.js
2224 - name : Use Node.js
2325 uses : actions/setup-node@v2
2426 with :
2527 node-version : 18
26-
28+ # Caché de los node_modules
2729 - name : Cache node modules
2830 uses : actions/cache@v2
2931 with :
3032 path : node_modules
3133 key : ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
3234 restore-keys : |
3335 ${{ runner.OS }}-node-18-
36+ # Instalación de dependencias
3437 - run : npm ci
35-
38+ # Construye la aplicación y aplica pruebas
3639 Build-Application-Tests :
3740 runs-on : ubuntu-latest
41+
3842 steps :
39-
40- # Checkout your code into the container
43+
4144 - uses : actions/checkout@v3
4245 with :
43- # Making a pull_request on develop: Download the code from feature branch
46+ # Realizar un pull_request a ' develop': Descarga el codigo de la rama feature
4447 ref : ${{ github.event.pull_request.head.sha }}
45- # Setup node and npm to your path
48+
4649 - name : Use Node.js
4750 uses : actions/setup-node@v2
4851 with :
4952 node-version : 18
50- # Runs clean install of npm for automated environments
53+
5154 - run : npm ci
52- # Run tests
55+
5356 - name : Ejecutar pruebas
5457 run : npm test
55-
58+ # Despliegue en el ambiente de QA
5659 Deploy-to-QA :
5760 name : Deploy to Quality Assurance
61+ # Dependencias. Este job depende de la finalización exitosa de estos dos jobs.
5862 needs : [Setup-Cache-Dependencies, Build-Application-Tests]
5963 if : github.event_name == 'pull_request'
60- # Define the platform to work in
64+ # Sistema operativo en el que se ejecutará el trabajo.
6165 runs-on : ubuntu-latest
6266 environment :
67+ # Nombre del entorno donde se desplegará la aplicación.
6368 name : Development
64-
6569 steps :
70+ # Obtener el código fuente del repositorio.
6671 - name : Checkout code
6772 uses : actions/checkout@v3
68-
73+ # Instalar kubectl, herramienta de línea de comandos de Kubernetes.
6974 - name : Install kubectl
7075 uses : azure/setup-kubectl@v3
7176 with :
7277 version : ' v1.28.0'
7378 id : install
74-
79+ # Configura las credenciales de Amazon AWS para permitir la interacción con el servicio.
7580 - name : Configure AWS Credentials
7681 uses : aws-actions/configure-aws-credentials@v3
7782 with :
@@ -80,25 +85,25 @@ jobs:
8085 aws-region : ${{ secrets.AWS_DEFAULT_REGION }}
8186 role-to-assume : ${{ secrets.AWS_ROLE_TO_ASSUME }}
8287 role-session-name : ${{ secrets.AWS_ROLE_SESSION_NAME }}
83-
88+ # Actualizar la configuración de kubectl para interactuar con el clúster EKS.
8489 - name : Update kube config
8590 run : aws eks update-kubeconfig --name eks-demo --region us-east-2
86-
91+ # Desplegar la aplicación en EKS usando los archivos de configuración.
8792 - name : Deploy to EKS
8893 run : |
8994 kubectl apply -f eks/deployment-qa.yaml
9095 kubectl apply -f eks/service-qa.yaml
91-
96+ # Obtener valores de EKS para el ambiente de QA
9297 QA-EKS-Values :
9398 name : Get QA Kubernetes Values
9499 needs : [Setup-Cache-Dependencies, Deploy-to-QA]
95100 if : success()
96- # Define the platform to work in
97101 runs-on : ubuntu-latest
98102 environment :
99103 name : Development
100104
101105 steps :
106+
102107 - name : Checkout code
103108 uses : actions/checkout@v3
104109
@@ -107,7 +112,7 @@ jobs:
107112 with :
108113 version : ' v1.28.0'
109114 id : install
110-
115+
111116 - name : Configure AWS Credentials
112117 uses : aws-actions/configure-aws-credentials@v3
113118 with :
@@ -126,18 +131,17 @@ jobs:
126131 kubectl get deployment -n quality-assurance -o wide
127132 kubectl get service -n quality-assurance
128133 kubectl get pods -o wide -n quality-assurance
129-
130-
134+ # Despliegue en el ambiente de Staging
131135 Deploy-to-Stg :
132136 name : Deploy to Staging
133137 needs : [Setup-Cache-Dependencies, Build-Application-Tests]
134138 if : github.event.ref == 'refs/heads/main'
135- # Define the platform to work in
136139 runs-on : ubuntu-latest
137140 environment :
138141 name : Staging
139-
142+
140143 steps :
144+
141145 - name : Checkout code
142146 uses : actions/checkout@v3
143147
@@ -146,7 +150,7 @@ jobs:
146150 with :
147151 version : ' v1.28.0'
148152 id : install
149-
153+
150154 - name : Configure AWS Credentials
151155 uses : aws-actions/configure-aws-credentials@v3
152156 with :
@@ -155,25 +159,25 @@ jobs:
155159 aws-region : ${{ secrets.AWS_DEFAULT_REGION }}
156160 role-to-assume : ${{ secrets.AWS_ROLE_TO_ASSUME }}
157161 role-session-name : ${{ secrets.AWS_ROLE_SESSION_NAME }}
158-
162+
159163 - name : Update kube config
160164 run : aws eks update-kubeconfig --name eks-demo --region us-east-2
161-
165+
162166 - name : Deploy to EKS
163167 run : |
164168 kubectl apply -f eks/deployment-stg.yaml
165169 kubectl apply -f eks/service-stg.yaml
166-
170+ # Obtener valores de EKS para el ambiente de Staging
167171 Stg-EKS-Values :
168172 name : Get Stg Kubernetes Values
169173 needs : [Setup-Cache-Dependencies, Deploy-to-Stg]
170174 if : success()
171- # Define the platform to work in
172175 runs-on : ubuntu-latest
173176 environment :
174177 name : Staging
175178
176179 steps :
180+
177181 - name : Checkout code
178182 uses : actions/checkout@v3
179183
@@ -182,7 +186,7 @@ jobs:
182186 with :
183187 version : ' v1.28.0'
184188 id : install
185-
189+
186190 - name : Configure AWS Credentials
187191 uses : aws-actions/configure-aws-credentials@v3
188192 with :
@@ -201,16 +205,16 @@ jobs:
201205 kubectl get deployment -n staging -o wide
202206 kubectl get service -n staging
203207 kubectl get pods -o wide -n staging
204-
208+ # Despliegue en el ambiente de Producción
205209 Deploy-to-Prod :
206210 name : Deploy to Production
207211 needs : [Setup-Cache-Dependencies, Deploy-to-Stg]
208- # Define the platform to work in
209212 runs-on : ubuntu-latest
210213 environment :
211214 name : Production
212-
215+
213216 steps :
217+
214218 - name : Checkout code
215219 uses : actions/checkout@v3
216220
@@ -219,7 +223,7 @@ jobs:
219223 with :
220224 version : ' v1.28.0'
221225 id : install
222-
226+
223227 - name : Configure AWS Credentials
224228 uses : aws-actions/configure-aws-credentials@v3
225229 with :
@@ -228,23 +232,25 @@ jobs:
228232 aws-region : ${{ secrets.AWS_DEFAULT_REGION }}
229233 role-to-assume : ${{ secrets.AWS_ROLE_TO_ASSUME }}
230234 role-session-name : ${{ secrets.AWS_ROLE_SESSION_NAME }}
231-
235+
232236 - name : Update kube config
233237 run : aws eks update-kubeconfig --name eks-demo --region us-east-2
234-
238+
235239 - name : Deploy to EKS
236240 run : |
237241 kubectl apply -f eks/deployment-prd.yaml
238242 kubectl apply -f eks/service-prd.yaml
239-
243+ # Push de la imagen Docker al registro ECR
240244 Image-to-ECR :
241245 name : Docker Image to ECR
242246 needs : [Setup-Cache-Dependencies, Deploy-to-Prod]
243247 if : success()
244248 runs-on : ubuntu-latest
245249 environment :
246250 name : Production
251+
247252 steps :
253+
248254 - name : Checkout code
249255 uses : actions/checkout@v3
250256
@@ -262,32 +268,38 @@ jobs:
262268 aws-region : ${{ secrets.AWS_DEFAULT_REGION }}
263269 role-to-assume : ${{ secrets.AWS_ROLE_TO_ASSUME }}
264270 role-session-name : ${{ secrets.AWS_ROLE_SESSION_NAME }}
265-
271+ # Iniciar sesión en el Amazon ECR para poder subir imágenes Docker
266272 - name : Login to Amazon ECR
267273 id : login-ecr
268274 uses : aws-actions/amazon-ecr-login@v1
269275 with :
276+ # Enmascara la contraseña en los logs por razones de seguridad
270277 mask-password : ' true'
271-
278+ # Etiquetar y subir la imagen Docker al ECR
272279 - name : Tag, and push docker image to Amazon ECR
273280 env :
281+ # Dirección del registro ECR.
274282 ECR_REGISTRY : ${{ steps.login-ecr.outputs.registry }}
283+ # Nombre del repositorio.
275284 ECR_REPOSITORY : express
285+ # Etiqueta de la imagen basada en el SHA del commit
276286 IMAGE_TAG : ${{ github.sha }}
277287 run : |
288+ # Construir la imagen Docker con la etiqueta "latest".
278289 docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
290+ # Subir la imagen al Amazon ECR.
279291 docker push $ECR_REGISTRY/$ECR_REPOSITORY
280-
292+ # Obtener valores de EKS para el ambiente de Producción
281293 Prod-EKS-Values :
282294 name : Get Prod Kubernetes Values
283295 needs : [Setup-Cache-Dependencies, Deploy-to-Prod]
284296 if : success()
285- # Define the platform to work in
286297 runs-on : ubuntu-latest
287298 environment :
288299 name : Production
289300
290301 steps :
302+
291303 - name : Checkout code
292304 uses : actions/checkout@v3
293305
@@ -296,7 +308,7 @@ jobs:
296308 with :
297309 version : ' v1.28.0'
298310 id : install
299-
311+
300312 - name : Configure AWS Credentials
301313 uses : aws-actions/configure-aws-credentials@v3
302314 with :
@@ -316,7 +328,7 @@ jobs:
316328 kubectl get service -n production
317329 kubectl get pods -o wide -n production
318330
319- # Call workflow: " create release"
331+ # Llamada al workflow de tipo evento: create-release para la creación de una release
320332 - name : trigger create release
321333 if : success()
322334 uses : peter-evans/repository-dispatch@v2
@@ -325,4 +337,3 @@ jobs:
325337 repository : ${{ github.repository }}
326338 event-type : create-release
327339 client-payload : ' { "base_branch": "${{ github.base_ref }}" }'
328- #
0 commit comments