Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
64 changes: 64 additions & 0 deletions .github/scripts/deploy-instance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

current_datetime=$(echo -n ${CURRENT_DATE} | md5sum | head -c 10)
echo "NAMESPACE : ci-{{INSTANCE}}-ns-pm4"
helm repo add processmaker ${HELM_REPO} --username ${HELM_USERNAME} --password ${HELM_PASSWORD} && helm repo update

if ! kubectl get namespace/ci-{{INSTANCE}}-ns-pm4 >/dev/null 2>&1; then
echo "New instance. Creating Namespace"
kubectl create namespace ci-{{INSTANCE}}-ns-pm4
echo "Creating DB"
# Generate random password
echo "Generating MySQL Password"
export MYSQL_PASSWORD=$(openssl rand -base64 12 | tr -dc 'a-zA-Z0-9' | head -c 16)
echo "Update instance yamls"
echo "Current Directory"
pwd
ls -lah

sed -i "s/{{MYSQL_PASSWORD}}/$MYSQL_PASSWORD/" .github/templates/db.yaml

echo "Creating DB :: pm4_ci-{{INSTANCE}}"
cat .github/templates/db.yaml
kubectl apply -f .github/templates/db.yaml --v=4

while true; do
DBSTATUS=$(kubectl get job mysql-setup-job-ci-{{INSTANCE}} -o jsonpath='{.status.succeeded}')
if [[ "$DBSTATUS" == "1" ]]; then
echo "MySQL Setup Job has completed."
break
else
echo "MySQL Setup Job is still running. Checking again in 10 seconds..."
sleep 10
fi
done

echo "Removing Job"
kubectl delete job mysql-setup-job-ci-{{INSTANCE}}
echo "Deploying Instance :: ci-{{INSTANCE}}"
sed -i "s/{{MYSQL_PASSWORD}}/$MYSQL_PASSWORD/g" .github/templates/instance.yaml
cat .github/templates/instance.yaml

helm install --timeout 75m -f .github/templates/instance.yaml ci-{{INSTANCE}} processmaker/enterprise \
--set deploy.pmai.openaiApiKey=${OPEN_AI_API_KEY} \
--set analytics.awsAccessKey=${ANALYTICS_AWS_ACCESS_KEY} \
--set analytics.awsSecretKey=${ANALYTICS_AWS_SECRET_KEY} \
--set dockerRegistry.password=${REGISTRY_PASSWORD} \
--set dockerRegistry.url=${REGISTRY_HOST} \
--set dockerRegistry.username=${REGISTRY_USERNAME} \
--set twilio.sid=${TWILIO_SID} \
--set twilio.token=${TWILIO_TOKEN}
else
echo "Instance exists. Running upgrade and bouncing pods"
helm upgrade --timeout 60m ci-{{INSTANCE}} processmaker/enterprise --version ${versionHelm}

#Bounce pods
webPod=$(kubectl get pods -n ci-{{INSTANCE}}-ns-pm4|grep web|awk '{print $1}')
schedulerPod=$(kubectl get pods -n ci-{{INSTANCE}}-ns-pm4|grep scheduler|awk '{print $1}')
queuePod=$(kubectl get pods -n ci-{{INSTANCE}}-ns-pm4|grep queue|awk '{print $1}')
kubectl delete pod $webPod $schedulerPod $queuePod -n ci-{{INSTANCE}}-ns-pm4
fi

export INSTANCE_URL=https://ci-{{INSTANCE}}$DOM_EKS
echo "INSTANCE_URL=${INSTANCE_URL}" >> "$GITHUB_ENV"
./pm4-k8s-distribution/images/pm4-tools/pm wait-for-instance-ready
18 changes: 18 additions & 0 deletions .github/scripts/gh_comment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /bin/sh
if [ -z "$INSTANCE_URL" ]; then
echo "No instance URL"
exit 0
fi

project=$1
pull_id=$2

if [ $pull_id -eq 0 ]; then
exit 0
fi

comment_url=https://api.github.com/repos/ProcessMaker/$project/issues/$pull_id/comments

curl $comment_url \
-s -H "Authorization: token $GITHUB_COMMENT" \
-X POST -d "{\"body\": \"QA server K8S was successfully deployed $INSTANCE_URL\"}"
53 changes: 53 additions & 0 deletions .github/templates/db.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
apiVersion: batch/v1
kind: Job
metadata:
name: mysql-setup-job-ci-{{INSTANCE}}
spec:
template:
spec:
containers:
- name: mysql-client
image: mysql:8
command: ["/bin/bash"]
args:
- -c
- |
mysql -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASSWORD" <<EOF
# Create databases
CREATE DATABASE IF NOT EXISTS \`pm4_ci-{{INSTANCE}}\`;
CREATE DATABASE IF NOT EXISTS \`pm4_ci-{{INSTANCE}}_ai\`;
# Create users
CREATE USER IF NOT EXISTS 'user_ci-{{INSTANCE}}'@'%' IDENTIFIED BY '{{MYSQL_PASSWORD}}';
CREATE USER IF NOT EXISTS 'user_ci-{{INSTANCE}}_ai'@'%' IDENTIFIED BY '{{MYSQL_PASSWORD}}';
# Grant permissions
GRANT ALL PRIVILEGES ON \`pm4_ci-{{INSTANCE}}\`.* TO 'user_ci-{{INSTANCE}}'@'%';
GRANT ALL PRIVILEGES ON \`pm4_ci-{{INSTANCE}}_ai\`.* TO 'user_ci-{{INSTANCE}}_ai'@'%';
FLUSH PRIVILEGES;
# Output the created resources
SELECT CONCAT('Created database: pm4_', 'ci-{{INSTANCE}}') AS setup_info;
SELECT CONCAT('Created database: pm4_', 'ci-{{INSTANCE}}', '_ai') AS setup_info;
SELECT CONCAT('Created user: user_', 'ci-{{INSTANCE}}', '@%') AS setup_info;
SELECT CONCAT('Created user: user_', 'ci-{{INSTANCE}}', '_ai@%') AS setup_info;
SELECT CONCAT('Password: ', '{{MYSQL_PASSWORD}}') AS setup_info;
EOF
env:
- name: IMAGE_TAG
valueFrom:
fieldRef:
fieldPath: metadata.annotations['image-tag']
- name: DB_HOST
valueFrom:
secretKeyRef:
name: mysql-secrets
key: DB_HOST
- name: DB_USER
valueFrom:
secretKeyRef:
name: mysql-secrets
key: DB_USER
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-secrets
key: DB_PASSWORD
restartPolicy: Never
67 changes: 67 additions & 0 deletions .github/templates/instance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
appVersion: {{IMAGE_TAG}}
appConfig:
https: false
subdomain: .engk8s.processmaker.net
customSecurityPolicy: true
customSecurityPolicyUrl: 'https://adobexdplatform.com https://*.quicksight.aws.amazon.com https://www.canva.com https://excalidraw.com https://www.figma.com https://flocus.com https://www.framer.com https://giphy.com https://lookerstudio.google.com https://maps.google.com https://docs.google.com https://www.loom.com https://miro.com https://mixpanel.com https://pitch.com https://prezi.com https://www.sketch.com https://www.slideshare.net https://supademo.com https://www.tableau.com https://forms.app https://vimeo.com https://www.youtube.com'
deploy:
pmai:
openaiHost: pmai-svc.{{pmai-system}}.svc.cluster.local
deployDb: false
dbHost: pm4-eng-stm-rds-cluster.cluster-ckz0mnb6cuna.us-east-1.rds.amazonaws.com
dbName: pm4_ci-{{INSTANCE}}_ai
dbUsername: user_ci-{{INSTANCE}}_ai
dbPassword: {{MYSQL_PASSWORD}}
volumes:
# TO DO: get EFS working in cicd cluster
#storageClassName: 'efs-sc'
storage:
diskSize: 1Gi
executor:
diskSize: 10Gi
resources:
# Add resources step on Deployments
# Executor - Scheduler - Queue - Web-UI
enable: false
database:
deploy: false
host: pm4-eng-stm-rds-cluster.cluster-ckz0mnb6cuna.us-east-1.rds.amazonaws.com
name: pm4_ci-{{INSTANCE}}
username: user_ci-{{INSTANCE}}
password: {{MYSQL_PASSWORD}}
analytics:
awsRegion: us-east-1
awsS3Bucket: tmp-security-logs-to-download
intercom:
appId: memgomb2
company: ENG
env: ENG
identityKey: sooZOeIDJI02_388erBqFH4PtbF_aflV--r4Fjmr
logrocket:
enable: false
appId: gbuoqe/processmaker-4
dashboard: https://us-east-1.quicksight.aws.amazon.com/sn/embed/share/accounts/780138555770/dashboards/a0194bdc-a1a6-4414-85a2-ab652ded98e3?directory_alias=processmaker
collaborativeModeler:
host: socketio-dev.processmaker.net
port: 443
cdata:
connectors:
docusign: 5543444B5541535544424141454E545041325246353431324354303100000000000000000000000050524F434553534D00004645344A374E443159345A550000
excel: 5258444B5541535544424141454E545041325246353431324354303100000000000000000000000050524F434553534D00005A395A42364A5944463452350000
github: 4647444B5541535544424141454E545041325246353431324354303100000000000000000000000050524F434553534D000056424530563739353759384A0000
slack: 4643444B5541535544424141454E545041325246353431324354303100000000000000000000000050524F434553534D00004635523734413735455A32360000
gmail: 4431444B5541535544424141454E545041325246353431324354303100000000000000000000000050524F434553534D00005356434441465847303144570000
api: 4641444B5541535544424141454E545041325246353431324354303100000000000000000000000050524F434553534D00004750533442365456343939530000
twilio:
enable: true
phoneNumber: "+17243958155"
redis:
diskSize: 2Gi
cicd: true
otel: true
loki: true
s3Backup:
# Deploy S3 Backup CronJob
deploy: false
stm:
enable: false
Loading
Loading