espacio #13
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: 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 install | |
# Configurar EAS Update (se asegura de que el proyecto esté configurado correctamente) | |
- name: Configure EAS Update | |
run: eas update:configure | |
env: | |
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} # Expo token desde variables de entorno | |
# Publicar actualización de EAS (esto reemplaza `expo publish`) | |
- name: Publish EAS Update | |
run: eas update --non-interactive | |
env: | |
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} # Expo token desde variables de entorno | |
# Compilar la aplicación Android | |
- name: EAS Build (Android) | |
run: eas build --platform android --non-interactive | |
env: | |
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} # Expo token desde variables de entorno | |
# Compilar la aplicación iOS | |
- name: EAS Build (iOS) | |
run: eas build --platform ios --non-interactive | |
env: | |
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} # Expo token desde variables de entorno | |
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 }} | |
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> |