Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCRVS-6000: Infrastructure deployment, monitoring and maintenance updates #789

Merged
merged 198 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
198 commits
Select commit Hold shift + click to select a range
50e996f
fix conflicts
euanmillar Nov 8, 2023
c1de407
add amends from cdpi-living-lab repository
naftis Nov 16, 2023
0560ad0
setup pem file
naftis Nov 16, 2023
db578b0
fix merge conflict
naftis Nov 16, 2023
e1825d9
add libsodium to dev dependencies
naftis Nov 16, 2023
9b19e19
configure provisioning and deployment script so that any user with pr…
rikukissa Nov 24, 2023
a2618d1
compress and encrypt backup directories before sending to backup server
rikukissa Nov 24, 2023
254a20a
supply backup password to backup cronjob
rikukissa Nov 27, 2023
6efc958
supply backup encryption passphrase from github secrets
rikukissa Nov 27, 2023
a65b672
hide openhim-console by default
rikukissa Nov 27, 2023
2a637d3
hide openhim-api by default
rikukissa Nov 27, 2023
91446f7
Modularise playbook tasks, use only one playbook for all deployment s…
rikukissa Nov 29, 2023
2a56a0d
add filebeat so logs can be accessed, monitored by kibana
rikukissa Nov 29, 2023
3cbc67a
fix kibana address
rikukissa Nov 29, 2023
bf6900d
Setup new alerts: SSH login, error in backup logs, available disk spa…
rikukissa Nov 29, 2023
e638bc7
add ansible task for creating user accounts for maintainers with 2FA …
rikukissa Nov 29, 2023
f0f633d
add new alerts for log alerts and ssh alerts
rikukissa Nov 29, 2023
286e955
pass initial metabase sequal file to metabase as a config file so dep…
rikukissa Nov 29, 2023
2d5b806
temporarily allow root login again until we set up deployment users
rikukissa Nov 29, 2023
11d602f
add port to port forwarding container names so multiple ports can be …
rikukissa Dec 3, 2023
d94b847
Changes to environment provisioning script and log file handling
euanmillar Dec 7, 2023
955c8f5
remove vagrant files
rikukissa Dec 8, 2023
5fbae00
Merge branch 'infra-improvements' of github.com:opencrvs/opencrvs-far…
rikukissa Dec 8, 2023
595c943
remove references to sudo password
rikukissa Dec 8, 2023
6c71498
remove VPN mentions for now
rikukissa Dec 8, 2023
8454054
remove elastalert slack alert environment variable as it's not referr…
rikukissa Dec 8, 2023
df17c28
remove extra environment variables from deploy script call
rikukissa Dec 8, 2023
0c60360
remove proxy config from backup script
rikukissa Dec 8, 2023
9307beb
generate BACKUP_ENCRYPTION_PASSPHRASE for all github environments
rikukissa Dec 8, 2023
29fe10e
make log files be accessible by application group so SSH_USER can rea…
rikukissa Dec 8, 2023
eb4b447
remove node version matrices from new pipelines
rikukissa Dec 11, 2023
1796794
add separate inventory files for all environments
rikukissa Dec 12, 2023
cb93915
make docker manager1 reference dynamic
rikukissa Dec 12, 2023
0aaf347
Combine country config compose files to base deployment compose files…
rikukissa Dec 13, 2023
b205399
Production VPN (#809)
rikukissa Dec 13, 2023
2ccecb3
remove unused HOSTNAME parameter
rikukissa Dec 13, 2023
75413cf
fix a bug in environment creator script, make sure secrets are never …
rikukissa Dec 13, 2023
2daab78
add development environment to provisioning scripts
rikukissa Dec 13, 2023
c44100c
add development machine to inventory
rikukissa Dec 13, 2023
22160b2
remove unnecessary PEM setup step
rikukissa Dec 14, 2023
64a1522
always use the same ansible variables
rikukissa Dec 14, 2023
b004ff0
fix ansible variable reference
rikukissa Dec 14, 2023
c038766
remove global ansible user setting
rikukissa Dec 14, 2023
13cae90
add back missing dockerhub username
rikukissa Dec 14, 2023
7a46278
disable SSH login with root login if provisioning is not done as root
rikukissa Dec 14, 2023
573edb1
convert inventory files to yml so ssh keys and users can be directly …
rikukissa Dec 14, 2023
ab2e6d3
add Tahmid's public key
rikukissa Dec 14, 2023
ebd69ff
fix inventory file reference
rikukissa Dec 14, 2023
0401b83
add development to machines that can be deployed to
rikukissa Dec 14, 2023
b562faf
fix known hosts mechanism in deployment pipelines
rikukissa Dec 14, 2023
1b563dc
make environment seletion in deploy.sh dynamic
rikukissa Dec 14, 2023
2e78eb7
volume mount metabase init file as docker has a file size limit of 50…
rikukissa Dec 14, 2023
142c03f
copy the whole project directory to the server
rikukissa Dec 14, 2023
b5c3492
send core compose files to the server
rikukissa Dec 14, 2023
5a63ba6
fix common file paths
rikukissa Dec 14, 2023
2ed836e
fix environment compose file
rikukissa Dec 14, 2023
da3cb96
use absolute paths in the compose file
rikukissa Dec 14, 2023
dbfab44
add debug log
rikukissa Dec 14, 2023
ab12b7e
remove deploy log file temporarily
rikukissa Dec 14, 2023
a9afe40
remove matrices from deployment pipelines
rikukissa Dec 14, 2023
837b61f
add debug log
rikukissa Dec 14, 2023
3eb9bbd
debug github action
rikukissa Dec 15, 2023
625e842
fix deploy pipeline syntax
rikukissa Dec 15, 2023
8bebba6
add variables to debug step
rikukissa Dec 15, 2023
f4f94fe
make debugging an option
rikukissa Dec 15, 2023
f4410e1
fix pipeline syntax
rikukissa Dec 15, 2023
9107eae
just a commit to make pipeline update on github
rikukissa Dec 15, 2023
19a67ac
more syntax fixes
rikukissa Dec 15, 2023
4e26a70
more syntax fixes
rikukissa Dec 15, 2023
008d092
more syntax fixes
rikukissa Dec 15, 2023
5d4b622
only define overlay net in the main deploy docker compose so that it …
rikukissa Dec 15, 2023
298db77
remove files from target server infrastructure directory if those fil…
rikukissa Dec 15, 2023
d584daf
fix deploy path
rikukissa Dec 15, 2023
c7aa311
do a docker login as part of deployment
rikukissa Dec 15, 2023
84b4049
only volume link minio admin's config to the container so it wont wri…
rikukissa Dec 15, 2023
39deb98
remove container names as docker swarm do not support those
rikukissa Dec 15, 2023
db4dca9
fix path for elasticsearch config
rikukissa Dec 15, 2023
07a18b2
change the clear data script so that it doesn't touch /data directory…
rikukissa Dec 15, 2023
0eff586
add missing env variables
rikukissa Dec 15, 2023
69d1d7f
do not use interactive shell
rikukissa Dec 15, 2023
6d01727
stop debug mode from starting if its not explicitly enables
rikukissa Dec 15, 2023
48f9278
add development to seed pipeline
rikukissa Dec 15, 2023
89b4d4d
add pipeline for clearing an environment
rikukissa Dec 18, 2023
abffde1
rename pipeline
rikukissa Dec 18, 2023
882c432
temporarily adda a push trigger to clear environment
rikukissa Dec 18, 2023
a5dc5e7
Revert "temporarily adda a push trigger to clear environment"
rikukissa Dec 18, 2023
30a1bf7
fix reset script file reference, reuse clear-environment pipeline in …
rikukissa Dec 18, 2023
27b70ec
run clearing through ssh
rikukissa Dec 18, 2023
fabc512
add missing ssh secrets
rikukissa Dec 18, 2023
1115e30
fix pipeline reference in deploy script
rikukissa Dec 18, 2023
2ac8e6c
make clear-environment reusable
rikukissa Dec 18, 2023
a290a1e
debug why no reset
rikukissa Dec 18, 2023
a09f322
add migration run to clear-environment pipeline
rikukissa Dec 18, 2023
f74ae7e
remove data clearing from deploy script
rikukissa Dec 18, 2023
636dbe7
try without conditionals
rikukissa Dec 18, 2023
3e52c42
try with a true string
rikukissa Dec 18, 2023
98c876e
use singlequotes
rikukissa Dec 18, 2023
4ee1c1d
update staging server fingerprint
rikukissa Dec 18, 2023
90e3e98
add output for reset step
rikukissa Dec 18, 2023
e64a31a
fix synta
rikukissa Dec 18, 2023
043b1fb
change staging IP
rikukissa Dec 18, 2023
3b1d801
fix pexpect reference
rikukissa Dec 18, 2023
e149707
remove pyexpect completely
rikukissa Dec 18, 2023
9b3f3a7
remove python3-docker module as we do not have any ansible docker com…
rikukissa Dec 18, 2023
6118754
try again with the module as its needed for logging in to docker
rikukissa Dec 18, 2023
c735bbd
run provisioning tasks through qa
rikukissa Dec 18, 2023
b55bf9c
add jump host
rikukissa Dec 18, 2023
3ea4a4f
update known hosts once more
rikukissa Dec 18, 2023
1c51bbb
add more logging
rikukissa Dec 18, 2023
2d6f26e
update qa fingerprint
rikukissa Dec 18, 2023
2a6dc3c
lower timeout limits
rikukissa Dec 18, 2023
4ab046a
restart ssh as root
rikukissa Dec 18, 2023
7a3e48a
change ssh restart method for ubuntu 23
rikukissa Dec 18, 2023
dc53b53
make a 1-1 mapping to github environments and deployed environments. …
rikukissa Dec 18, 2023
e94956a
add back docker login
rikukissa Dec 18, 2023
ee421e3
make it possible to pass SSH args to deploy script
rikukissa Dec 19, 2023
c9b4085
fix
rikukissa Dec 19, 2023
8423a30
make it possible to supply additional ssh parameters for clear script
rikukissa Dec 19, 2023
2dc45b9
updates to create environment script
rikukissa Dec 19, 2023
8a305c4
configure jump host for production
rikukissa Dec 19, 2023
73c807c
update production ssh fingerprint
rikukissa Dec 19, 2023
ca8ba16
make production a 2-server deployment
rikukissa Dec 19, 2023
2ff4c2a
add missing jump host definition for docker-workers
rikukissa Dec 20, 2023
6fa9a68
ignore VPN and other allowed addresses in fail2ban
rikukissa Dec 20, 2023
9d82a8e
update staging and prod docker composed
rikukissa Dec 20, 2023
5de4684
fix jinja template
rikukissa Dec 20, 2023
60d9fdc
configure rsync to not change file permissions
rikukissa Dec 21, 2023
9b7f7e7
add debug
rikukissa Dec 21, 2023
e56aefb
remove -a from rsync so it doesnt try to change permissions
rikukissa Dec 21, 2023
43a70a8
add wireguard data partition, ensure files in deployment directory ar…
rikukissa Dec 21, 2023
8cc1ce7
make setting ownership recursive
rikukissa Dec 21, 2023
2c9be00
set read parmissions to others in /opt/opencrvs so docker users can r…
rikukissa Dec 21, 2023
77d37d1
increase fail2ban limits
rikukissa Dec 21, 2023
bc07dd5
attach traefik to vpn network
rikukissa Dec 21, 2023
03e0d6a
make ssh user configurable for port-forwarding script
rikukissa Dec 21, 2023
0cd4095
update wg-easy
rikukissa Dec 21, 2023
0f84db9
update wg-east
rikukissa Dec 21, 2023
97e42f7
fix cert resolver for vpn
rikukissa Dec 21, 2023
dc3ae4d
use github container registry and latest version for wg-easy
rikukissa Dec 21, 2023
68f173e
pass wireguard password variable through deployment pipeline
rikukissa Dec 21, 2023
6aa4a35
pass all github deployment environment variables to docker swarm depl…
rikukissa Dec 21, 2023
282faee
move environments variables to right function
rikukissa Dec 21, 2023
3dfcf5e
make a separate function that reads and supplies the env variables
rikukissa Dec 21, 2023
e1d6211
remove KNOWN_HOSTS from env variables
rikukissa Dec 21, 2023
6ec1842
remove more variables, fix escape
rikukissa Dec 21, 2023
fb8bb83
make sure KNOWN_HOSTS wont leak to deploy step
rikukissa Dec 21, 2023
94f8392
remove debug logging
rikukissa Dec 21, 2023
ddbeac5
only set traefik to vpn network on QA where Wireguard server is
rikukissa Dec 22, 2023
080e8bc
add validation to make sure all environment variables are set
rikukissa Dec 22, 2023
445d52c
download core compose iles before validating environment variables
rikukissa Dec 22, 2023
9523d5d
fix curl urls when downloading core compose files
rikukissa Dec 22, 2023
214e4f9
remove default latest value from country config version
rikukissa Dec 22, 2023
36283a4
fix country config version variable not going to docker compose files
rikukissa Dec 22, 2023
8d3fd92
fix compose env file order
rikukissa Dec 22, 2023
f2bbb66
fix environment variable filtering
rikukissa Dec 22, 2023
f5d1f67
add pipeline for resetting user's 2FA
rikukissa Jan 4, 2024
bf6aeee
fix name of the pipeline
rikukissa Jan 4, 2024
505bd64
trick github into showing the new pipeline
rikukissa Jan 4, 2024
2fefebe
fetch repo first
rikukissa Jan 4, 2024
c71aaf5
use jump host
rikukissa Jan 4, 2024
489c8e2
add debug step
rikukissa Jan 4, 2024
b072e49
remove unnecessary matrix definition
rikukissa Jan 4, 2024
1139e06
remove debugging code
rikukissa Jan 4, 2024
032318e
use docker config instead of volume mounts where possible
rikukissa Jan 4, 2024
843c839
add read and execute rights for others to the deployment directory as…
rikukissa Jan 4, 2024
1f95ee7
create a jump user for QA, allow definining multiple ssh keys for users
rikukissa Jan 4, 2024
bd60b39
do not add 2factor for jump users
rikukissa Jan 4, 2024
ab36738
use new jump user in inventory files as well
rikukissa Jan 4, 2024
d6cdd4c
set infobip environment variables as optional, add missing required e…
rikukissa Jan 4, 2024
a956c8c
add support for 1-infinite replicas
rikukissa Jan 4, 2024
8e3e481
add missing network
rikukissa Jan 4, 2024
5c78aa2
add missing export to VERSION variable
rikukissa Jan 5, 2024
748222f
remove demo deployment configuration for now
rikukissa Jan 5, 2024
7fe32bb
Create a backup restore cron on staging (#812)
euanmillar Jan 5, 2024
de4f252
fix snapshot script restore reference
rikukissa Jan 5, 2024
841a779
remove openhim base config
rikukissa Jan 5, 2024
2846314
remove WIREGUARD_ADMIN_PASSWORD reference from production deployment …
rikukissa Jan 8, 2024
c3a9b09
remove authorized_keys file
rikukissa Jan 8, 2024
08aec94
Merge branch 'release-v1.3.2' of github.com:opencrvs/opencrvs-farajal…
rikukissa Jan 9, 2024
7860b77
add debug logging for clear all data script
rikukissa Jan 10, 2024
98cb151
define REPLICAS variable before validating it
rikukissa Jan 10, 2024
7602d1b
fix syntax error in clear script
rikukissa Jan 10, 2024
954cfec
automate updating branches on release
rikukissa Jan 10, 2024
7a03473
Merge branch 'release-v1.4.0' into infra-improvements
rikukissa Jan 10, 2024
e819962
switch back to previous traefik port definition
rikukissa Jan 12, 2024
460ad7a
rename 2factor to two_factor
rikukissa Jan 16, 2024
210e7e6
add default true value for two_factor
rikukissa Jan 16, 2024
eb40db6
Merge branch 'release-v1.3.2' of github.com:opencrvs/opencrvs-farajal…
rikukissa Jan 18, 2024
ce29cb2
[OCRVS-6437] Forward Elastalert emails through country config (#851)
rikukissa Jan 22, 2024
8608fb5
[OCRVS-6350] Disable root (#849)
rikukissa Jan 22, 2024
f68ecd6
add history timestamps for user terminal history (#848)
rikukissa Jan 22, 2024
e33ef87
add playbook for ubuntu to update security patches automatically (#846)
rikukissa Jan 22, 2024
67ef318
Merge branch 'release-v1.4.0' into infra-improvements
rikukissa Jan 22, 2024
2181e92
Merge branch 'infra-improvements' of github.com:opencrvs/opencrvs-far…
rikukissa Jan 22, 2024
928a2d0
fix staging + prod key access to backup server
rikukissa Jan 24, 2024
4bc7e14
update prod & staging jump keys
rikukissa Jan 24, 2024
70e2eae
fix manager hostname reference
rikukissa Jan 24, 2024
a9cb29f
add a mechanism for defining additional SSH public keys that can logi…
rikukissa Jan 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/clear-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Reset environment
run-name: Reset data on ${{ github.event.inputs.environment }}
on:
workflow_call:
inputs:
environment:
required: true
type: string
workflow_dispatch:
inputs:
environment:
type: choice
description: Environment to reset
required: true
default: 'development'
options:
- staging
- qa
- development
jobs:
reset-data:
name: 'Reset data'
environment: ${{ github.event.inputs.environment }}
runs-on: ubuntu-20.04
timeout-minutes: 60
steps:
- name: Clone country config resource package
uses: actions/checkout@v3
with:
fetch-depth: 0
path: './${{ github.event.repository.name }}'

- name: Read known hosts
run: |
cd ${{ github.event.repository.name }}
echo "KNOWN_HOSTS<<EOF" >> $GITHUB_ENV
sed -i -e '$a\' ./infrastructure/.known-hosts
cat ./infrastructure/.known-hosts >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ env.KNOWN_HOSTS }}

- name: Reset data
env:
HOST: ${{ vars.DOMAIN }}
ENV: ${{ vars.ENVIRONMENT_TYPE }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_HOST: ${{ secrets.SSH_HOST }}
REPLICAS: ${{ vars.REPLICAS }}
MONGODB_ADMIN_USER: ${{ secrets.MONGODB_ADMIN_USER }}
MONGODB_ADMIN_PASSWORD: ${{ secrets.MONGODB_ADMIN_PASSWORD }}
ELASTICSEARCH_SUPERUSER_PASSWORD: ${{ secrets.ELASTICSEARCH_SUPERUSER_PASSWORD }}
MINIO_ROOT_USER: ${{ secrets.MINIO_ROOT_USER }}
MINIO_ROOT_PASSWORD: ${{ secrets.MINIO_ROOT_PASSWORD }}
SSH_ARGS: ${{ vars.SSH_ARGS }}
run: |
ssh $SSH_USER@$SSH_HOST $SSH_ARGS "
ELASTICSEARCH_ADMIN_USER=elastic \
ELASTICSEARCH_ADMIN_PASSWORD=$ELASTICSEARCH_SUPERUSER_PASSWORD \
MONGODB_ADMIN_USER=$MONGODB_ADMIN_USER \
MONGODB_ADMIN_PASSWORD=$MONGODB_ADMIN_PASSWORD \
MINIO_ROOT_USER=$MINIO_ROOT_USER \
MINIO_ROOT_PASSWORD=$MINIO_ROOT_PASSWORD \
/opt/opencrvs/infrastructure/clear-all-data.sh $REPLICAS"

echo "Running migrations..."
echo
ssh $SSH_USER@$SSH_HOST $SSH_ARGS "
ELASTICSEARCH_ADMIN_USER=elastic \
ELASTICSEARCH_ADMIN_PASSWORD=$ELASTICSEARCH_SUPERUSER_PASSWORD \
/opt/opencrvs/infrastructure/run-migrations.sh"
57 changes: 40 additions & 17 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy(production)
name: Deploy (production)
run-name: Deploy to ${{ github.event.inputs.environment }} core=${{ github.event.inputs.core-image-tag }} country config=${{ github.event.inputs.countryconfig-image-tag }}
on:
workflow_dispatch:
Expand All @@ -7,33 +7,32 @@ on:
type: choice
description: Environment to deploy to
required: true
default: 'production'
default: 'staging'
options:
- production
- staging
core-image-tag:
description: Core DockerHub image tag
required: true
default: 'v1.4.0'
countryconfig-image-tag:
description: Your Country Config DockerHub image tag
required: true
deploy-script-environment:
type: choice
description: Deploy script environment
required: true
default: 'production'
options:
- production
- demo

jobs:
deploy:
environment: ${{ github.event.inputs.environment }}
runs-on: ubuntu-20.04
timeout-minutes: 60
strategy:
matrix:
node-version: [16.20.0]
steps:
- uses: trstringer/manual-approval@v1
with:
secret: ${{ github.TOKEN }}
approvers: euanmillar,rikukissa
minimum-approvals: 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change:

  • Countries will need to change these to match their own approvers (document)

issue-title: 'Deploy (Prod): core: ${{ github.event.inputs.core-image-tag }} country config: ${{ github.event.inputs.countryconfig-image-tag }}'
issue-body: 'Please approve or deny the deployment of core: ${{ github.event.inputs.core-image-tag }} country config: ${{ github.event.inputs.countryconfig-image-tag }} to production'
exclude-workflow-initiator-as-approver: false
- name: Clone core
uses: actions/checkout@v3
with:
Expand All @@ -57,17 +56,29 @@ jobs:
cd opencrvs-core
git checkout ${{ github.event.inputs.core-image-tag }}

- name: Read known hosts
run: |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change:

.known-hosts file needs to be placed in infrastructure/.known-hosts. Example known-hosts file. All servers that Github Actions connects to need to be listed in this file.

ssh-keyscan can be used to generate entries for each server e.g.

ssh-keyscan -H farajaland.opencrvs.org,165.22.205.62

cd ${{ github.event.repository.name }}
echo "KNOWN_HOSTS<<EOF" >> $GITHUB_ENV
sed -i -e '$a\' ./infrastructure/.known-hosts
cat ./infrastructure/.known-hosts >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
known_hosts: ${{ env.KNOWN_HOSTS }}

- name: Unset KNOWN_HOSTS variable
run: |
echo "KNOWN_HOSTS=" >> $GITHUB_ENV

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
password: ${{ secrets.DOCKER_TOKEN }}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change:

  • DOCKER_PASSWORD Github Secret is replaced with DOCKER_TOKEN. Both provisioning and deployment pipelines are affected. More details here.

- name: Wait for images to be available
run: |
Expand All @@ -88,28 +99,40 @@ jobs:
env:
DOMAIN: ${{ vars.DOMAIN }}
REPLICAS: ${{ vars.REPLICAS }}
NOTIFICATION_TRANSPORT: ${{ vars.NOTIFICATION_TRANSPORT }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_HOST: ${{ secrets.SMTP_HOST }}
SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }}
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
SMTP_SECURE: ${{ secrets.SMTP_SECURE }}
ALERT_EMAIL: ${{ secrets.ALERT_EMAIL }}
DOCKERHUB_ACCOUNT: ${{ secrets.DOCKERHUB_ACCOUNT }}
DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_REPO }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
KIBANA_USERNAME: ${{ secrets.KIBANA_USERNAME }}
KIBANA_PASSWORD: ${{ secrets.KIBANA_PASSWORD }}
MONGODB_ADMIN_USER: ${{ secrets.MONGODB_ADMIN_USER }}
MONGODB_ADMIN_PASSWORD: ${{ secrets.MONGODB_ADMIN_PASSWORD }}
ELASTICSEARCH_SUPERUSER_PASSWORD: ${{ secrets.ELASTICSEARCH_SUPERUSER_PASSWORD }}
MINIO_ROOT_USER: ${{ secrets.MINIO_ROOT_USER }}
MINIO_ROOT_PASSWORD: ${{ secrets.MINIO_ROOT_PASSWORD }}
EMAIL_API_KEY: ${{ secrets.EMAIL_API_KEY }}
INFOBIP_SENDER_ID: ${{ secrets.INFOBIP_SENDER_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
INFOBIP_GATEWAY_ENDPOINT: ${{ secrets.INFOBIP_GATEWAY_ENDPOINT }}
INFOBIP_API_KEY: ${{ secrets.INFOBIP_API_KEY }}
SENDER_EMAIL_ADDRESS: ${{ secrets.SENDER_EMAIL_ADDRESS }}
SUPER_USER_PASSWORD: ${{ secrets.SUPER_USER_PASSWORD }}
CONTENT_SECURITY_POLICY_WILDCARD: ${{ vars.CONTENT_SECURITY_POLICY_WILDCARD }}
SSH_ARGS: ${{ vars.SSH_ARGS }}
run: |
cd ./${{ github.event.repository.name }}
yarn deploy --clear_data=no --environment=${{ github.event.inputs.deploy-script-environment }} --host=${{ env.DOMAIN }} --version=${{ github.event.inputs.core-image-tag }} --country_config_version=${{ github.event.inputs.countryconfig-image-tag }} --country_config_path=../${{ github.event.repository.name }} --replicas=${{ env.REPLICAS }}
yarn deploy \
--clear_data=no \
--environment=${{ github.event.inputs.environment }} \
--host=${{ env.DOMAIN }} \
--ssh_host=${{ secrets.SSH_HOST }} \
--ssh_user=${{ secrets.SSH_USER }} \
--version=${{ github.event.inputs.core-image-tag }} \
--country_config_version=${{ github.event.inputs.countryconfig-image-tag }} \
--replicas=${{ env.REPLICAS }}
101 changes: 84 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy(development)
name: Deploy (development)
run-name: Deploy to ${{ github.event.inputs.environment }} with reset=${{ github.event.inputs.reset }} core=${{ github.event.inputs.core-image-tag }} country config=${{ github.event.inputs.countryconfig-image-tag }}
on:
workflow_dispatch:
Expand All @@ -11,6 +11,7 @@ on:
options:
- staging
- qa
- development
core-image-tag:
description: Core DockerHub image tag
required: true
Expand All @@ -19,23 +20,20 @@ on:
description: Your Country Config DockerHub image tag
required: true
reset:
type: choice
description: Whether to reset the environment
required: true
default: 'no'
options:
- 'yes'
- 'no'
type: boolean
description: Reset the environment
default: false
debug:
type: boolean
description: Open SSH session to the runner after deployment
default: false
jobs:
deploy:
environment: ${{ github.event.inputs.environment }}
runs-on: ubuntu-20.04
outputs:
outcome: ${{ steps.deploy.outcome }}
timeout-minutes: 60
strategy:
matrix:
node-version: [16.20.0]
steps:
- name: Clone core
uses: actions/checkout@v3
Expand All @@ -60,17 +58,29 @@ jobs:
cd opencrvs-core
git checkout ${{ github.event.inputs.core-image-tag }}

- name: Read known hosts
run: |
cd ${{ github.event.repository.name }}
echo "KNOWN_HOSTS<<EOF" >> $GITHUB_ENV
sed -i -e '$a\' ./infrastructure/.known-hosts
cat ./infrastructure/.known-hosts >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
known_hosts: ${{ env.KNOWN_HOSTS }}

- name: Unset KNOWN_HOSTS variable
run: |
echo "KNOWN_HOSTS=" >> $GITHUB_ENV

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Wait for images to be available
run: |
Expand All @@ -89,37 +99,94 @@ jobs:

- name: Deploy to ${{ github.event.inputs.environment }}
id: deploy
continue-on-error: ${{ github.event.inputs.debug == true }}
env:
DOMAIN: ${{ vars.DOMAIN }}
REPLICAS: ${{ vars.REPLICAS }}
NOTIFICATION_TRANSPORT: ${{ vars.NOTIFICATION_TRANSPORT }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_HOST: ${{ secrets.SMTP_HOST }}
SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }}
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
SMTP_SECURE: ${{ secrets.SMTP_SECURE }}
ALERT_EMAIL: ${{ secrets.ALERT_EMAIL }}
DOCKERHUB_ACCOUNT: ${{ secrets.DOCKERHUB_ACCOUNT }}
DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_REPO }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
KIBANA_USERNAME: ${{ secrets.KIBANA_USERNAME }}
KIBANA_PASSWORD: ${{ secrets.KIBANA_PASSWORD }}
MONGODB_ADMIN_USER: ${{ secrets.MONGODB_ADMIN_USER }}
MONGODB_ADMIN_PASSWORD: ${{ secrets.MONGODB_ADMIN_PASSWORD }}
ELASTICSEARCH_SUPERUSER_PASSWORD: ${{ secrets.ELASTICSEARCH_SUPERUSER_PASSWORD }}
MINIO_ROOT_USER: ${{ secrets.MINIO_ROOT_USER }}
MINIO_ROOT_PASSWORD: ${{ secrets.MINIO_ROOT_PASSWORD }}
EMAIL_API_KEY: ${{ secrets.EMAIL_API_KEY }}
INFOBIP_SENDER_ID: ${{ secrets.INFOBIP_SENDER_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
INFOBIP_GATEWAY_ENDPOINT: ${{ secrets.INFOBIP_GATEWAY_ENDPOINT }}
INFOBIP_API_KEY: ${{ secrets.INFOBIP_API_KEY }}
WIREGUARD_ADMIN_PASSWORD: ${{ secrets.WIREGUARD_ADMIN_PASSWORD }}
SENDER_EMAIL_ADDRESS: ${{ secrets.SENDER_EMAIL_ADDRESS }}
SUPER_USER_PASSWORD: ${{ secrets.SUPER_USER_PASSWORD }}
SSH_ARGS: ${{ vars.SSH_ARGS }}
CONTENT_SECURITY_POLICY_WILDCARD: ${{ vars.CONTENT_SECURITY_POLICY_WILDCARD }}
run: |
cd ./${{ github.event.repository.name }}
yarn deploy --clear_data=${{ github.event.inputs.reset }} --environment=${{ github.event.inputs.environment }} --host=${{ env.DOMAIN }} --version=${{ github.event.inputs.core-image-tag }} --country_config_version=${{ github.event.inputs.countryconfig-image-tag }} --country_config_path=../${{ github.event.repository.name }} --replicas=${{ env.REPLICAS }}
seed-data:
yarn deploy \
--clear_data=no \
--environment=${{ github.event.inputs.environment }} \
--host=${{ env.DOMAIN }} \
--ssh_host=${{ secrets.SSH_HOST }} \
--ssh_user=${{ secrets.SSH_USER }} \
--version=${{ github.event.inputs.core-image-tag }} \
--country_config_version=${{ github.event.inputs.countryconfig-image-tag }} \
--replicas=${{ env.REPLICAS }}

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event.inputs.debug == true }}
env:
DOMAIN: ${{ vars.DOMAIN }}
REPLICAS: ${{ vars.REPLICAS }}
NOTIFICATION_TRANSPORT: ${{ vars.NOTIFICATION_TRANSPORT }}
SMTP_PORT: ${{ secrets.SMTP_PORT }}
SMTP_HOST: ${{ secrets.SMTP_HOST }}
SMTP_USERNAME: ${{ secrets.SMTP_USERNAME }}
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
SMTP_SECURE: ${{ secrets.SMTP_SECURE }}
ALERT_EMAIL: ${{ secrets.ALERT_EMAIL }}
DOCKERHUB_ACCOUNT: ${{ secrets.DOCKERHUB_ACCOUNT }}
DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_REPO }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
KIBANA_USERNAME: ${{ secrets.KIBANA_USERNAME }}
KIBANA_PASSWORD: ${{ secrets.KIBANA_PASSWORD }}
MONGODB_ADMIN_USER: ${{ secrets.MONGODB_ADMIN_USER }}
MONGODB_ADMIN_PASSWORD: ${{ secrets.MONGODB_ADMIN_PASSWORD }}
ELASTICSEARCH_SUPERUSER_PASSWORD: ${{ secrets.ELASTICSEARCH_SUPERUSER_PASSWORD }}
MINIO_ROOT_USER: ${{ secrets.MINIO_ROOT_USER }}
MINIO_ROOT_PASSWORD: ${{ secrets.MINIO_ROOT_PASSWORD }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
WIREGUARD_ADMIN_PASSWORD: ${{ secrets.WIREGUARD_ADMIN_PASSWORD }}
INFOBIP_SENDER_ID: ${{ secrets.INFOBIP_SENDER_ID }}
INFOBIP_GATEWAY_ENDPOINT: ${{ secrets.INFOBIP_GATEWAY_ENDPOINT }}
INFOBIP_API_KEY: ${{ secrets.INFOBIP_API_KEY }}
SENDER_EMAIL_ADDRESS: ${{ secrets.SENDER_EMAIL_ADDRESS }}
SUPER_USER_PASSWORD: ${{ secrets.SUPER_USER_PASSWORD }}
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_ARGS: ${{ vars.SSH_ARGS }}
CONTENT_SECURITY_POLICY_WILDCARD: ${{ vars.CONTENT_SECURITY_POLICY_WILDCARD }}
reset:
needs: deploy
if: ${{ github.event.inputs.reset == 'yes' && needs.deploy.outputs.outcome == 'success' }}
if: ${{ github.event.inputs.reset == 'true' && needs.deploy.outputs.outcome == 'success' }}
uses: ./.github/workflows/clear-environment.yml
with:
environment: ${{ github.event.inputs.environment }}
secrets: inherit

seed-data:
needs: reset
if: ${{ github.event.inputs.reset == 'true' && needs.reset.outputs.outcome == 'success' }}
uses: ./.github/workflows/seed-data.yml
with:
environment: ${{ github.event.inputs.environment }}
Expand Down
Loading
Loading