Corrigiendo errores en el Workflow #2
This file contains hidden or 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: Test & Deploy to AWS | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Playwright | |
| run: npx playwright install --with-deps | |
| - name: Run tests | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_REGION: us-east-1 | |
| SQS_URL: ${{ secrets.SQS_URL }} | |
| SQS_RESULTADO_URL: ${{ secrets.SQS_RESULTADO_URL }} | |
| SQS_DLQ_URL: ${{ secrets.SQS_DLQ_URL }} | |
| OPENWEATHER_API_KEY: ${{ secrets.OPENWEATHER_API_KEY }} | |
| API_GATEWAY_URL: ${{ secrets.API_GATEWAY_URL }} | |
| run: npm test | |
| continue-on-error: true | |
| - name: Generate HTML report | |
| if: always() | |
| run: npm run test:report || echo "No report generated" | |
| - name: Upload test results to S3 | |
| if: always() | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| run: | | |
| if [ -d "playwright-report" ]; then | |
| npx ts-node scripts/uploadReportToS3.ts | |
| else | |
| echo "No report directory found" | |
| fi | |
| - name: Upload Playwright Report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: playwright-report | |
| path: playwright-report/ | |
| retention-days: 30 | |
| if-no-files-found: warn | |
| deploy-lambda: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' && success() | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Deploy Lambda Clima | |
| run: | | |
| if [ -f "lambda/index.js" ]; then | |
| cd lambda | |
| npm install --production | |
| zip -r clima.zip index.js node_modules/ | |
| aws lambda update-function-code \ | |
| --function-name Clima \ | |
| --zip-file fileb://clima.zip | |
| echo "✅ Lambda Clima deployed" | |
| else | |
| echo "⚠️ lambda/index.js not found, skipping deployment" | |
| fi | |
| - name: Deploy Lambda API Gateway | |
| run: | | |
| if [ -f "lambda/apiGatewayHandler.js" ]; then | |
| cd lambda | |
| zip -r api.zip apiGatewayHandler.js node_modules/ | |
| aws lambda update-function-code \ | |
| --function-name apiGatewayClima \ | |
| --zip-file fileb://api.zip | |
| echo "✅ Lambda API Gateway deployed" | |
| else | |
| echo "⚠️ lambda/apiGatewayHandler.js not found, skipping deployment" | |
| fi |