-
Notifications
You must be signed in to change notification settings - Fork 34
96 lines (79 loc) · 3.02 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
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
name: Deploy to ECR
on:
push:
branches: [ main, piyush-dev ]
jobs:
build:
name: Build Image
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ECR_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_ECR_SECRET_KEY }}
aws-region: ap-south-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: banodoco-frontend
IMAGE_TAG: latest
id: build-image
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Fill in the new image ID in the Amazon ECS task definition
env:
ECS_TASK_DEFINITION: .aws/task-definition.json
CONTAINER_NAME: backend-banodoco-frontend
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@c804dfbdd57f713b6c079302a4c01db7017a36fc
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
env:
ECS_SERVICE: backend-banodoco-frontend-service
ECS_CLUSTER: backend-banodoco-frontend-cluster
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
update-runner:
name: Update Background Runner
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create and activate virtual environment
run: |
python3 -m venv venv
source venv/bin/activate
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
source venv/bin/activate && pip install -r requirements.txt
- name: Create .env file
run: |
touch .env
echo "SERVER=production" > .env
echo "SERVER_URL=https://api.banodoco.ai" >> .env
echo "HOSTED_BACKGROUND_RUNNER_MODE=True" >> .env
echo "admin_email=${{ secrets.ADMIN_EMAIL }}" >> .env
echo "admin_password=${{ secrets.ADMIN_PASSWORD }}" >> .env
echo "ENCRYPTION_KEY=${{ secrets.FERNET_ENCRYPTION_KEY }}" >> .env
- name: Restart runner
run: |
if pkill -0 -f "banodoco_runner"; then
pkill -f "banodoco_runner"
fi
. venv/bin/activate && nohup python banodoco_runner.py > script_output.log 2>&1 &