-
-
Notifications
You must be signed in to change notification settings - Fork 1
61 lines (50 loc) · 1.86 KB
/
deploy.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
51
52
53
54
55
56
57
58
59
60
61
name: Docker Build & Deploy
on:
push:
branches:
- main
jobs:
Continuous-Integration:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build Docker Image
run: |
docker build -t streamlit-app \
--build-arg OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} \
--build-arg WEATHER_API_KEY=${{ secrets.WEATHER_API_KEY }} \
--build-arg SERPER_API_KEY=${{ secrets.SERPER_API_KEY }} \
--build-arg AMADEUS_API_KEY=${{ secrets.AMADEUS_API_KEY }} \
--build-arg AMADEUS_API_SECRET=${{ secrets.AMADEUS_API_SECRET }} .
Continuous-Delivery:
needs: Continuous-Integration
runs-on: self-hosted
steps:
- name: Authenticate to AWS ECR
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_DEFAULT_REGION }}
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v2
- name: Push Docker Image to ECR
run: |
docker tag streamlit-app:latest ${{ secrets.AWS_ECR_REPO_URI }}:latest
docker push ${{ secrets.AWS_ECR_REPO_URI }}:latest
Continuous-Deployment:
needs: Continuous-Delivery
runs-on: self-hosted
steps:
- name: Deploy to EC2
run: |
ssh -i ${{ secrets.SSH_KEY }} ubuntu@44.210.129.170 \
'docker pull ${{ secrets.AWS_ECR_REPO_URI }}:latest && \
docker stop streamlit-app || true && \
docker rm streamlit-app || true && \
docker run -d --name streamlit-app -p 8501:8501 ${{ secrets.AWS_ECR_REPO_URI }}:latest'
- name: Cleanup Old Images
if: always()
run: |
docker system prune -af