-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (45 loc) · 1.5 KB
/
pre-deployment.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: "Pre Deployment Script"
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build_app:
runs-on: ubuntu-latest
steps:
- name: Pull Repository
uses: actions/checkout@v2
- name: Setup and Install Node.Js
uses: actions/[email protected]
with:
node-version: "18.x"
cache: "yarn"
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Build Application
run: yarn run app:build
build_docker_image_and_push_to_ecr:
runs-on: ubuntu-latest
needs: build_app
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.REGION }}
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build and Push Docker Image to Amazon ECR
run: |
docker build -t ${{ secrets.REGISTRY_URL }}/${{ secrets.REPOSITORY_NAME }}:latest .
docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REPOSITORY_NAME }}:latest
- name: Deploy to Lambda
run: |
aws lambda update-function-code --function-name ${{ vars.FUNCTION_NAME }} --image-uri ${{ secrets.REGISTRY_URL }}/${{ secrets.REPOSITORY_NAME }}:latest