From a7698b995dafd25a545f1bdcc04307836ee0aa36 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 11 Apr 2024 14:55:17 +0530 Subject: [PATCH] Add a script to deploy test records --- packages/deployer/test/deploy-webapp.sh | 96 +++++++++++++++++++ .../application-deployment-request.yml | 15 +++ .../test/records/application-record.yml | 8 ++ 3 files changed, 119 insertions(+) create mode 100755 packages/deployer/test/deploy-webapp.sh create mode 100644 packages/deployer/test/records/application-deployment-request.yml create mode 100644 packages/deployer/test/records/application-record.yml diff --git a/packages/deployer/test/deploy-webapp.sh b/packages/deployer/test/deploy-webapp.sh new file mode 100755 index 0000000..96c02ce --- /dev/null +++ b/packages/deployer/test/deploy-webapp.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +# Repository URL +REPO_URL="https://github.com/snowball-tools-platform/test-progressive-web-app" + +# Get the latest commit hash from the repository +LATEST_HASH=$(git ls-remote $REPO_URL HEAD | awk '{print $1}') + +# Fetch the package.json file content +# Extract version from package.json content +package_json=$(wget -qO- "$REPO_URL/raw/$LATEST_HASH/package.json") +PACKAGE_VERSION=$(echo "$package_json" | jq -r '.version') + +# Current date and time for note +CURRENT_DATE_TIME=$(date -u) + +CONFIG_FILE=packages/deployer/config.yml +REGISTRY_BOND_ID="99c0e9aec0ac1b8187faa579be3b54f93fafb6060ac1fd29170b860df605be32" + +# Reference: https://git.vdb.to/cerc-io/test-progressive-web-app/src/branch/main/scripts + +APP_NAME=deployment-test-app + +# Get latest version from registry and increment application-record version +NEW_APPLICATION_VERSION=$(yarn --silent laconic -c $CONFIG_FILE cns record list --type ApplicationRecord --all --name "$APP_NAME" 2>/dev/null | jq -r -s ".[] | sort_by(.createTime) | reverse | [ .[] | select(.bondId == \"$REGISTRY_BOND_ID\") ] | .[0].attributes.version" | awk -F. -v OFS=. '{$NF += 1 ; print}') + +if [ -z "$NEW_APPLICATION_VERSION" ] || [ "1" == "$NEW_APPLICATION_VERSION" ]; then + # Set application-record version if no previous records were found + NEW_APPLICATION_VERSION=0.0.1 +fi + +# Generate application-record.yml with incremented version +RECORD_FILE=packages/deployer/test/records/application-record.yml + +cat > $RECORD_FILE < $REQUEST_RECORD_FILE <