-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (96 loc) · 3.29 KB
/
Copy pathtest-and-deploy.yml
File metadata and controls
112 lines (96 loc) · 3.29 KB
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
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