-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (118 loc) · 3.57 KB
/
deploy.yml
File metadata and controls
147 lines (118 loc) · 3.57 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
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
name: Deploy Lambda to AWS
on:
push:
branches:
- main
workflow_dispatch:
env:
AWS_REGION: us-east-1
jobs:
###########################################################
# BUILD + TEST + COVERAGE
###########################################################
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
defaults:
run:
working-directory: app
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: maven
- name: Build with Tests
run: mvn -B clean verify
- name: Publish Test Report
uses: dorny/test-reporter@v1
if: always()
with:
name: Maven Tests
path: app/target/surefire-reports/*.xml
reporter: java-junit
fail-on-error: false
- name: Upload Lambda JAR
uses: actions/upload-artifact@v4
with:
name: lambda-jar
path: app/target/lambda-identification-auth.jar
- name: Upload Coverage
uses: actions/upload-artifact@v4
with:
name: jacoco-report
path: app/target/site/jacoco
###########################################################
# SONARCLOUD
###########################################################
sonarqube:
name: SonarCloud Analysis
runs-on: ubuntu-latest
needs: build-and-test
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: maven
- name: Run SonarCloud
working-directory: app
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn -B verify sonar:sonar \
-Dsonar.projectKey=video2frames_lambda-identification-auth \
-Dsonar.organization=video2frames \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.token=${SONAR_TOKEN} \
-Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
###########################################################
# DEPLOY
###########################################################
deploy:
name: Deploy Lambda + Infra
runs-on: ubuntu-latest
needs:
- build-and-test
- sonarqube
environment: Production
permissions:
id-token: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Download Lambda Artifact
uses: actions/download-artifact@v4
with:
name: lambda-jar
path: app/target
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_ACCESS_SECRET }}
aws-region: ${{ env.AWS_REGION }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
- name: Terraform Init
run: terraform init
- name: Terraform Plan
run: terraform plan -out=tfplan
env:
TF_VAR_lambda_jar_path: app/target/lambda-identification-auth.jar
- name: Terraform Apply
run: terraform apply -auto-approve tfplan
env:
TF_VAR_lambda_jar_path: app/target/lambda-identification-auth.jar