-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (49 loc) · 1.87 KB
/
main.yml
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
name: Deploy Node.js API to AWS Lightsail
on:
push:
branches:
- main # O workflow será executado ao fazer push na branch main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checar o código
- name: Checkout
uses: actions/[email protected]
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.10.3
# - name: Build and push
# uses: docker/build-push-action@v6
# with:
# context: ./
# push: true
# file: ./docker/pipeline.dockerfile
# version: 26.1.2
# tags: |
# robyrt/api-catalago:latest
# robyrt/api-catalago:${{ github.run_number }}
# Step 3: Logar no Amazon ECR
- name: Log in to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
# Step 4: Construir a imagem Docker
- name: Build Docker image
run: |
docker build -t lightsailDeployApi ./Docker/production-Dockerfile
docker tag lightsailDeployApi:latest ${{ secrets.AWS_ECR_REGISTRY }}/my-api:latest
# Step 5: Subir a imagem para o Amazon ECR
- name: Push Docker image to Amazon ECR
run: |
docker push ${{ secrets.AWS_ECR_REGISTRY }}/lightsailDeployApi:latest
# Step 6: Atualizar o container no Lightsail (usando o AWS CLI)
- name: Deploy to AWS Lightsail
run: |
aws lightsail push-container-image --region ${{ secrets.AWS_REGION }} --image my-api:latest
aws lightsail create-container-service-deployment --region ${{ secrets.AWS_REGION }} --service-name my-api-service --containers file://containers.json