-
Notifications
You must be signed in to change notification settings - Fork 1
46 lines (38 loc) · 1.45 KB
/
sean-be-ci-cd.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
name: Sean Back End CI/CD
on:
push:
branches:
- sean-be-cicd
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
ref: sean-be-cicd
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Amazon ECR
env:
AWS_ACCESS_KEY_ID: ${{ secrets.SEAN_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.SEAN_AWS_SECRET_ACCESS_KEY }}
run: |
aws configure set aws_access_key_id $SEAN_AWS_ACCESS_KEY_ID
aws configure set aws_secret_access_key $SEAN_AWS_SECRET_ACCESS_KEY
aws configure set default.region ap-southeast-2
aws ecr get-login-password --region ap-southeast-2 | docker login --username AWS --password-stdin 975049946739.dkr.ecr.ap-southeast-2.amazonaws.com
- name: Build Docker image
run: |
docker build -t my-app:latest .
working-directory: flask-app
- name: Tag Docker image
run: |
IMAGE_TAG=$(date +%Y%m%d%H%M%S)
docker tag my-app:latest 975049946739.dkr.ecr.ap-southeast-2.amazonaws.com:$IMAGE_TAG
docker tag my-app:latest 975049946739.dkr.ecr.ap-southeast-2.amazonaws.com:latest
- name: Push Docker image to ECR
run: |
docker push 975049946739.dkr.ecr.ap-southeast-2.amazonaws.com:latest
docker push 975049946739.dkr.ecr.ap-southeast-2.amazonaws.com:$IMAGE_TAG