From 0dd8b9621211194bbb048c8e4a08d1401194ae6f Mon Sep 17 00:00:00 2001 From: zramsay Date: Fri, 31 Jan 2025 13:00:36 -0500 Subject: [PATCH] updates --- .env | 3 + .github/workflows/publish-to-laconic.yml | 38 ++++++ config.yml | 8 -- scripts/deploy-frontend.sh | 146 +++++++++++++++++++++++ 4 files changed, 187 insertions(+), 8 deletions(-) create mode 100644 .env create mode 100644 .github/workflows/publish-to-laconic.yml delete mode 100644 config.yml create mode 100755 scripts/deploy-frontend.sh diff --git a/.env b/.env new file mode 100644 index 0000000..a077bea --- /dev/null +++ b/.env @@ -0,0 +1,3 @@ +REGISTRY_BOND_ID=e2271e59c85b500f97d7efcef320e7ebf5c470f1580d4479302ba20b32624adc +DEPLOYER_LRN=lrn://vaasl-provider/deployers/webapp-deployer-api.apps.vaasl.io +AUTHORITY=vaasl diff --git a/.github/workflows/publish-to-laconic.yml b/.github/workflows/publish-to-laconic.yml new file mode 100644 index 0000000..2328746 --- /dev/null +++ b/.github/workflows/publish-to-laconic.yml @@ -0,0 +1,38 @@ +name: Publish Namadillo to Laconic Registry +on: + release: + types: [published] + push: + branches: + - main + - deploy-webapp + +env: + CERC_REGISTRY_USER_KEY: ${{ secrets.CICD_LACONIC_USER_KEY }} + CERC_REGISTRY_BOND_ID: ${{ secrets.CICD_LACONIC_BOND_ID }} + CERC_REGISTRY_RPC_ENDPOINT: "https://laconicd-sapo.laconic.com" + CERC_REGISTRY_GQL_ENDPOINT: "https://laconicd-sapo.laconic.com/api" + CERC_REGISTRY_CHAIN_ID: "laconic-testnet-2" + CERC_REGISTRY_DEPLOYMENT_HOSTNAME: namadillo + DEPLOYER_LRN: "lrn://vaasl-provider/deployers/webapp-deployer-api.apps.vaasl.io" + +jobs: + laconic_publish: + runs-on: ubuntu-latest + steps: + - name: "Clone project repository" + uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: "Enable Yarn" + run: corepack enable + - name: "Install registry CLI" + run: | + npm config set @cerc-io:registry https://git.vdb.to/api/packages/cerc-io/npm/ + npm install -g @cerc-io/laconic-registry-cli + - name: "Install jq" + run: sudo apt -y update && sudo apt -y install jq + - name: "Publish Application Record" + run: scripts/deploy-frontend.sh diff --git a/config.yml b/config.yml deleted file mode 100644 index 1bb7bcf..0000000 --- a/config.yml +++ /dev/null @@ -1,8 +0,0 @@ -services: - registry: - rpcEndpoint: https://laconicd-sapo.laconic.com - gqlEndpoint: https://laconicd-sapo.laconic.com/api - userKey: - bondId: - chainId: laconic-testnet-2 - gasPrice: 0.001alnt diff --git a/scripts/deploy-frontend.sh b/scripts/deploy-frontend.sh new file mode 100755 index 0000000..c8b6281 --- /dev/null +++ b/scripts/deploy-frontend.sh @@ -0,0 +1,146 @@ +#!/bin/bash + +source .env +echo "Using REGISTRY_BOND_ID: $REGISTRY_BOND_ID" +echo "Using DEPLOYER_LRN: $DEPLOYER_LRN" +echo "Using AUTHORITY: $AUTHORITY" + +# Repository URL +REPO_URL="https://git.vdb.to/mito-systems/ranger-app" + +# Get the latest commit hash from the repository +LATEST_HASH=$(git ls-remote $REPO_URL HEAD | awk '{print $1}') + +PACKAGE_VERSION=0.0.15 + +# Current date and time for note +CURRENT_DATE_TIME=$(date -u) + +## TODO make this +CONFIG_FILE=priv-config.yml + +# Reference: https://git.vdb.to/cerc-io/test-progressive-web-app/src/branch/main/scripts + +# Get latest version from registry and increment application-record version +NEW_APPLICATION_VERSION=$(laconic -c $CONFIG_FILE registry record list --type ApplicationRecord --all --name "wild" 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.6 +fi + +# Generate application-record.yml with incremented version +cat >./records/application-record.yml <./records/application-deployment-request.yml <