-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (43 loc) · 1.33 KB
/
ecr_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
name: Build and push Docker image to Amazon ECR
on:
push:
branches:
- main
paths:
- Dockerfile
- src/**
- main.py
- pyproject.toml
- poetry.lock
- .github/workflows/ecr_deployment.yml
workflow_dispatch:
permissions:
id-token: write # Required for requesting the Json Web Token (JWT)
contents: read # Required for actions/checkout
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
id: checkout-code
uses: actions/checkout@v4
- name: Configure AWS credentials from OIDC
id: configure-aws-credentials
uses: aws-actions/configure-aws-credentials@v4
with:
audience: sts.amazonaws.com
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE_ARN }}
role-session-name: build-and-push
- name: Log in to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push docker image to Amazon ECR
id: build-and-push
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
IMAGE_TAG: latest
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG