-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (33 loc) · 1.62 KB
/
letterboxd.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
name: Letterboxd
on:
workflow_run:
workflows: [ infra ]
types: [ completed ]
branches: [ main ]
env:
APP_NAME: letterboxd
AWS_REGION: eu-west-2
jobs:
build-and-deploy:
name: Build and deploy
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- name: 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: ${{ env.AWS_REGION }}
- name: Build Docker image
run: docker build -f Dockerfile.${{ env.APP_NAME }} -t ${{ env.APP_NAME }} .
- name: Tag Docker image
run: docker tag ${{ env.APP_NAME }}:latest ${{ secrets.AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.APP_NAME }}:latest
- name: Authenticate Docker CLI to use AWS ECR
run: aws ecr get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com
- name: Push Docker image to ECR image registry
run: docker push ${{ secrets.AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.APP_NAME }}:latest
- name: Update Lambda function code to use latest image
run: aws lambda update-function-code --function-name ${{ env.APP_NAME }} --image-uri ${{ secrets.AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.APP_NAME }}:latest