-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (65 loc) · 2.93 KB
/
develop.yml
File metadata and controls
82 lines (65 loc) · 2.93 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
name: Deploy Trinity App to ECS
on:
push:
branches: [ feature/aws ]
jobs:
build-deploy:
name: Build & Deploy
runs-on: ubuntu-latest
env:
STAGE: develop
SERVICE_NAME: trinity
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 17
- name: Instalar wrapper do Maven (se necessário)
run: mvn -N io.takari:maven:wrapper -Dmaven=3.9.9
- name: Instalar xmllint
run: sudo apt-get update && sudo apt-get install -y libxml2-utils
- name: Extrair versão do pom.xml
id: version
run: |
VERSION=$(xmllint --xpath "/*[local-name()='project']/*[local-name()='version']/text()" pom.xml)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Configurar credenciais AWS
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.DEV_AWS_REGION }}
- name: Login no Amazon ECR
uses: aws-actions/amazon-ecr-login@v2
- name: Build imagem com GraalVM
run: |
docker build -t ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}:latest \
-t ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}:${{ steps.version.outputs.version }} .
- name: Push da imagem para ECR
run: |
docker push ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}:latest
docker push ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}:${{ steps.version.outputs.version }}
- name: Criar nova task definition com nova imagem
id: task-def
run: |
IMAGE_URI=${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}:${{ steps.version.outputs.version }}
aws ecs describe-task-definition \
--task-definition trinity-task-dev \
--query "taskDefinition" > task-definition.json
jq ".containerDefinitions[0].image = \"${IMAGE_URI}\"" task-definition.json > task-def-updated.json
jq "del(.taskDefinitionArn, .revision, .status, .requiresAttributes, .compatibilities, .registeredAt, .registeredBy)" task-def-updated.json > final-task-def.json
NEW_TASK_DEF_ARN=$(aws ecs register-task-definition \
--cli-input-json file://final-task-def.json \
--query "taskDefinition.taskDefinitionArn" \
--output text)
echo "task_def_arn=$NEW_TASK_DEF_ARN" >> $GITHUB_OUTPUT
- name: Atualizar serviço ECS
run: |
aws ecs update-service \
--cluster studio-trek-cluster-dev \
--service trinity-service-dev \
--task-definition ${{ steps.task-def.outputs.task_def_arn }} \
--force-new-deployment