-
Notifications
You must be signed in to change notification settings - Fork 3
32 lines (28 loc) · 1.09 KB
/
deploy.yml
File metadata and controls
32 lines (28 loc) · 1.09 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
name: Deploy to EC2 via SSM
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install AWS CLI
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
- name: Deploy via SSM
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
EC2_INSTANCE_ID: ${{ secrets.EC2_INSTANCE_ID }}
run: |
aws ssm send-command \
--document-name "AWS-RunShellScript" \
--instance-ids "$EC2_INSTANCE_ID" \
--region "$AWS_REGION" \
--comment "Deploying via SSM" \
--parameters 'commands=["cd /home/ubuntu/CustomsChatBotAI", "git pull", "docker compose down && docker compose up -d --build", "if [ $(docker inspect -f \"{{.State.Running}}\" flask-ai-server) = true ]; then docker image prune -af; fi"]' \
--output text