-
Notifications
You must be signed in to change notification settings - Fork 1
35 lines (30 loc) · 1.09 KB
/
deploy.yaml
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
name: Deploy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
name: build docker image
steps:
- name: Git Checkout
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
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@v2
- name: Build, tag, and push image to Amazon ECR
run: |
cd demo/lambda/src
docker build -t ${{ steps.login-ecr.outputs.registry }}/demo-awscd-2024:$GITHUB_SHA -f Dockerfile .
docker push ${{ steps.login-ecr.outputs.registry }}/demo-awscd-2024:$GITHUB_SHA
- name: Replace the Docker image tag with Git SHA in deploy.yaml
run: |
export GIT_SHA=$(echo $GITHUB_SHA | cut -c1-8)
sed -i "s/:.*/:$GIT_SHA/" demo/lambda/deployment/deploy.yaml