-
Notifications
You must be signed in to change notification settings - Fork 79
75 lines (72 loc) · 2.87 KB
/
bahmni_standard_docker_env.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
name: Deploy to Bahmni Standard Docker Env
on:
push:
branches:
- master
paths:
- 'bahmni-standard/**'
- '.github/workflows/bahmni_standard_docker_env.yaml'
repository_dispatch:
types:
- bahmni-helm-publish-event
- openmrs-db-publish-event
- openelis-publish-event
- odoo-publish-event
- odoo-connect-publish-event
- dcm4chee-pacs-publish-event
- bahmni-proxy-publish-event
workflow_dispatch:
inputs:
update_bahmni_option:
description: 'Choose the option to update Bahmni. "Update without removing volumes" or "Update and remove volumes"'
required: true
type: choice
default: update_without_removing_volumes
options:
- update_without_removing_volumes
- update_and_remove_volumes
env:
UPDATE_BAHMNI_OPTION: ${{ github.event.inputs.update_bahmni_option || 'update_without_removing_volumes'}}
jobs:
deploy:
name: Deploy to Remote Instance
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.BAHMNI_AWS_ID }}
aws-secret-access-key: ${{ secrets.BAHMNI_AWS_SECRET }}
aws-region: ap-south-1
role-to-assume: ${{ secrets.BAHMNI_INFRA_ADMIN_ROLE }}
role-duration-seconds: 1200 # 20 mins
role-session-name: BahmniInfraAdminSession
- name: Create/Update Containers
run: |
if [ "$UPDATE_BAHMNI_OPTION" == "update_without_removing_volumes" ]; then
command="docker compose --env-file .env.dev up -d"
elif [ "$UPDATE_BAHMNI_OPTION" == "update_and_remove_volumes" ]; then
command="docker compose --env-file .env.dev down -v && docker compose --env-file .env.dev up -d"
fi
INSTANCE_ID=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=bahmni-standard-docker" "Name=instance-state-name,Values=running" --query "Reservations[].Instances[].InstanceId" --output text)
if [ -z "$INSTANCE_ID" ]; then
echo "Instance not running"
else
aws ssm send-command \
--instance-ids "$INSTANCE_ID" \
--document-name "AWS-RunShellScript" \
--comment "Update running containers" \
--parameters '{
"commands": [
". /home/ubuntu/.bash_profile",
"git pull -r",
"docker compose --env-file .env.dev pull",
"'"$command"'",
"docker image prune -f"
],
"workingDirectory": [
"/home/ubuntu/bahmni-docker/bahmni-standard"
]
}' | jq '.Command | {CommandId: .CommandId, Parameters: .Parameters, Status: .Status}'
fi