-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (44 loc) · 1.74 KB
/
deploy-suscriptor.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
name: Deploy Lambda - Suscriptor a tópico SNS
on:
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Clone repository
run: |
git clone https://github.com/guillevalin/devops-challenge.git
cd devops-challenge
- name: Set up Docker Buildx
run: |
docker buildx create --use
- name: Configure AWS CLI
run: |
aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}
aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws configure set region us-east-1
- name: Build and push Docker image
env:
DOCKER_REPO: 296062555964.dkr.ecr.us-east-1.amazonaws.com/app-suscriptor
LAMBDA_IMAGE_TAG: "latest"
run: |
cd devops-challenge/app-suscriptor
aws ecr get-login-password --region us-east-1 | docker login -u AWS --password-stdin 296062555964.dkr.ecr.us-east-1.amazonaws.com
docker build -t $DOCKER_REPO:$LAMBDA_IMAGE_TAG .
docker push $DOCKER_REPO:$LAMBDA_IMAGE_TAG
- name: Deploy to AWS Lambda
env:
LAMBDA_FUNCTION_NAME: "app-suscriptor"
LAMBDA_ROLE: ${{ secrets.LAMBDA_ROLE }}
DOCKER_REPO_URI: "296062555964.dkr.ecr.us-east-1.amazonaws.com/app-suscriptor:latest"
run: |
aws lambda create-function \
--function-name $LAMBDA_FUNCTION_NAME \
--package-type Image \
--code ImageUri=$DOCKER_REPO_URI \
--role $LAMBDA_ROLE \
--region us-east-1 \
|| aws lambda update-function-code \
--function-name $LAMBDA_FUNCTION_NAME \
--image-uri $DOCKER_REPO_URI \
--region us-east-1