forked from BahmniIndiaDistro/bahmni-india-package
-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (41 loc) · 1.56 KB
/
bahmni_gok_dev_env_deploy.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
name: Deploy to Bahmni HWC Dev Environment
on:
workflow_dispatch:
schedule:
- cron: '0 * * * *' # Runs every hour
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_HWC_AWS_ID }}
aws-secret-access-key: ${{ secrets.BAHMNI_HWC_AWS_SECRET }}
aws-region: ap-south-1
- name: Create/Update Containers
run: |
INSTANCE_ID=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=GoK QA" "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": [
". /root/.bashrc",
"git pull -r",
"docker compose pull",
"docker compose up -d",
"docker image prune -f",
"docker compose restart proxy"
],
"workingDirectory": [
"/home/ubuntu/bahmni-india-package"
]
}' | jq '.Command | {CommandId: .CommandId, Parameters: .Parameters, Status: .Status}'
fi