This repository has been archived by the owner on Apr 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
121 lines (106 loc) · 4.43 KB
/
human-detection-deployment.yaml
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Deploy HDM to AWS
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
pull_request:
branches: [ main ]
paths:
- HumanDetection/**
- .github/human-detection-deployment.yaml
- '!**.md'
- '!**.pdf'
- '!**.docx'
- '!**.gitignore'
- '!**.txt'
push:
branches: [ main ]
paths:
- HumanDetection/**
- .github/human-detection-deployment.yaml
- '!**.md'
- '!**.pdf'
- '!**.docx'
- '!**.gitignore'
- '!**.txt'
env:
ECR_REGISTRY_ALIAS: p3i3q7f7
ECR_REPOSITORY: human-detection-repository # set this to your Amazon ECR repository name
ECS_SERVICE: human-detection-service # set this to your Amazon ECS service name
ECS_CLUSTER: human-detection-cluster # set this to your Amazon ECS cluster name
# set this to the path to your Amazon ECS task definition
ECS_TASK_DEFINITION: .aws/human-detection-task-definition.json
# file, e.g. .aws/task-definition.json
HDM_CONTAINER_NAME: human-detection-container # set this to the name of the API container in the
# containerDefinitions section of your task definition
RABBIT_MQ_EXCHANGE_NAME: human-detection-exchange
RABBIT_MQ_QUEUE_NAME: human-detection-queue
INTRUSION_MANAGEMENT_API_URL: https://hllwa7dyek.execute-api.eu-west-3.amazonaws.com/v1/intrusion-management-api
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS credentials (us-east-1)
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v1
with:
registry-type: public
- name: Build, tag, and push docker hdm image to Amazon ECR Public
id: build-hdm-image
env:
ECR_REGISTRY: ${{ steps.login-ecr-public.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
RABBIT_MQ_URL: ${{ secrets.RABBIT_MQ_URL }}
RABBIT_MQ_USERNAME: ${{ secrets.RABBIT_MQ_USERNAME }}
RABBIT_MQ_PASSWORD: ${{ secrets.RABBIT_MQ_PASSWORD }}
REDIS_URL: ${{ secrets.REDIS_URL }}
run: |
cd HumanDetection/human-detection-module
docker build -t $ECR_REGISTRY/$ECR_REGISTRY_ALIAS/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REGISTRY_ALIAS/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REGISTRY_ALIAS/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Configure AWS credentials (change to eu-west-3 region)
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-3
- name: Update HDM container in ECS task definition
id: build-task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.HDM_CONTAINER_NAME }}
image: ${{ steps.build-hdm-image.outputs.image }}
environment-variables: |
RABBIT_MQ_URL=${{ secrets.RABBIT_MQ_URL }}
RABBIT_MQ_USERNAME=${{ secrets.RABBIT_MQ_USERNAME }}
RABBIT_MQ_PASSWORD=${{ secrets.RABBIT_MQ_PASSWORD }}
RABBIT_MQ_EXCHANGE_NAME=${{ env.RABBIT_MQ_EXCHANGE_NAME }}
RABBIT_MQ_QUEUE_NAME=${{ env.RABBIT_MQ_QUEUE_NAME }}
REDIS_URL=${{ secrets.REDIS_URL }}
INTRUSION_MANAGEMENT_API_URL=${{ env.INTRUSION_MANAGEMENT_API_URL }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/[email protected]
with:
task-definition: ${{ steps.build-task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: false