-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
26 lines (26 loc) · 1.36 KB
/
.travis.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
dist: focal
env:
global:
lambda_name=s3-bucket-watcher
ecr_repo_name=itaig
language: minimal
services:
- docker
before_install:
- pip install -U pip
- pip install jq
- curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
- unzip awscliv2.zip &>/dev/null
- rm -f awscliv2.zip
- sudo ./aws/install
- aws --version
- export PATH=$PATH:$HOME/.local/bin
- docker build -t ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${ecr_repo_name}:${TRAVIS_BRANCH}-${TRAVIS_BUILD_NUMBER} .
after_success:
- aws ecr get-login-password --region ${AWS_REGION} | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com &>/dev/null
- docker push ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${ecr_repo_name}:${TRAVIS_BRANCH}-${TRAVIS_BUILD_NUMBER}
- ecr_image_sha=$(aws ecr list-images --repository-name ${ecr_repo_name} | jq -r --arg travis_search "$TRAVIS_BRANCH-$TRAVIS_BUILD_NUMBER" '.imageIds[] | select(.imageTag == $travis_search) | .imageDigest')
- ecr_image_uri="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${ecr_repo_name}@${ecr_image_sha}"
- aws lambda update-function-code --function-name ${lambda_name} --image-uri ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${ecr_repo_name}@${ecr_image_sha} &>/dev/null
- echo "Allow 30 seconds for the function to complete the update"
- sleep 30