-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (97 loc) · 3.22 KB
/
github_cd.yaml
File metadata and controls
103 lines (97 loc) · 3.22 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Continuous Deployment Workflow
on:
workflow_dispatch:
release:
types: [published]
permissions:
contents: read
jobs:
release-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Install Hatch
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Build release distributions
run: |
hatch build
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/
pypi-publish:
runs-on: ubuntu-latest
needs:
- release-build
permissions:
id-token: write
environment:
name: release
url: https://pypi.org/p/chatbot_nam685/
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
continue-on-error: true
upload-docker-images:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker images
run: |
# Define public ECR repository URL
PUBLIC_ECR_URL=public.ecr.aws/e7b5q5z5/nam685
# LangGraph API server
docker build -t chatbot -f src/chatbot/Dockerfile .
docker tag chatbot:latest $PUBLIC_ECR_URL/chatbot:${{ github.sha }}
# API
docker build -t chatbot-api -f api/Dockerfile .
docker tag chatbot-api:latest $PUBLIC_ECR_URL/chatbot-api:${{ github.sha }}
# UI
docker build -t chatbot-ui -f ui/Dockerfile ./ui
docker tag chatbot-ui:latest $PUBLIC_ECR_URL/chatbot-ui:${{ github.sha }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4.1.0
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: Log in to Amazon ECR
run: |
aws ecr-public get-login-password --region us-east-1 | \
docker login --username AWS --password-stdin public.ecr.aws
- name: Push Docker images to ECR
run: |
PUBLIC_ECR_URL=public.ecr.aws/e7b5q5z5/nam685
docker push $PUBLIC_ECR_URL/chatbot:${{ github.sha }}
docker push $PUBLIC_ECR_URL/chatbot-api:${{ github.sha }}
docker push $PUBLIC_ECR_URL/chatbot-ui:${{ github.sha }}
deploy-ecs-by-cloudformation:
runs-on: ubuntu-latest
needs:
- upload-docker-images
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4.1.0
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: Deploy CloudFormation stack
uses: aws-actions/aws-cloudformation-github-deploy@v1
with:
name: chatbot-ecs
template: ecs-infrastructure.yaml
parameter-overrides: "GitCommitHash=${{ github.sha }},KeyPairName=chatbot"