-
Notifications
You must be signed in to change notification settings - Fork 506
58 lines (55 loc) · 2.01 KB
/
crawler.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: Crawlers
on:
push:
branches:
- main
jobs:
build:
name: Build & Push Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build images & push to ECR
id: build-image
uses: docker/build-push-action@v4
with:
context: ./course/module-1
file: ./course/module-1/Dockerfile
tags: |
${{ steps.login-ecr.outputs.registry }}/crawler:${{ github.sha }}
${{ steps.login-ecr.outputs.registry }}/crawler:latest
push: true
deploy:
name: Deploy Crawler
runs-on: ubuntu-latest
needs: build
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Deploy Lambda Image
id: deploy-lambda
run: |
echo "Updating lambda with new image version $ECR_REPOSITORY/crawler:$PROJECT_VERSION..."
aws lambda update-function-code \
--function-name "arn:aws:lambda:$AWS_REGION:$AWS_ACCOUNT_ID:function:crawler" \
--image-uri $ECR_REPOSITORY/crawler:$PROJECT_VERSION
echo "Successfully updated lambda"
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
ECR_REPOSITORY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
PROJECT_VERSION: ${{ github.sha }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}