From e5a77b6930f6e64681d3872488c79699cf1fc000 Mon Sep 17 00:00:00 2001 From: zramsay Date: Wed, 19 Nov 2025 21:44:09 +0000 Subject: [PATCH] Update deploy.sh --- deploy.sh | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/deploy.sh b/deploy.sh index fd0f0ba..98295cd 100755 --- a/deploy.sh +++ b/deploy.sh @@ -3,12 +3,10 @@ # Exit on any error set -e -# Trigger - # Check for required positional arguments if [ $# -ne 2 ]; then echo "Error: Two arguments required" - echo "Usage: $0 " + echo "Usage: $0 " exit 1 fi @@ -24,16 +22,28 @@ if [ -z "$CERC_REGISTRY_BOND_ID" ]; then fi REPO_PATH="$1" -TAG="$2" +REF="$2" REPO="https://github.com/${REPO_PATH}" -# Get the commit hash for the tag using GitHub API -COMMIT_HASH=$(curl -s "https://api.github.com/repos/${REPO_PATH}/git/refs/tags/${TAG}" | jq -r '.object.sha') +# Get the commit hash - try as branch first, then as tag +COMMIT_HASH=$(curl -s "https://api.github.com/repos/${REPO_PATH}/commits/${REF}" | jq -r '.sha') if [ -z "$COMMIT_HASH" ] || [ "$COMMIT_HASH" = "null" ]; then - echo "Error: Could not find commit hash for tag $TAG" - exit 1 + # Fall back to tag lookup + COMMIT_HASH=$(curl -s "https://api.github.com/repos/${REPO_PATH}/git/refs/tags/${REF}" | jq -r '.object.sha') + if [ -z "$COMMIT_HASH" ] || [ "$COMMIT_HASH" = "null" ]; then + echo "Error: Could not find commit hash for ref $REF" + exit 1 + fi fi +# Use short commit hash for version +SHORT_HASH="${COMMIT_HASH:0:7}" +VERSION="${REF}-${SHORT_HASH}" + +echo "Deploying from ref: $REF" +echo "Commit hash: $COMMIT_HASH" +echo "Version: $VERSION" + # Create temporary files RECORD_FILE=tmp.rf.$$ CONFIG_FILE=$(mktemp) @@ -54,7 +64,7 @@ cat < "$RECORD_FILE" record: type: ApplicationRecord name: "$APP_NAME" - version: "$TAG" + version: "$VERSION" app_type: webapp repository: - "$REPO" @@ -92,11 +102,11 @@ if [ ! -z "$DEPLOYER_LRN" ]; then else echo "No payment required - skipping payment step" txHash="" -fi + fi -# Generate deployment request -echo "Generating deployment request..." -cat < "$RECORD_FILE" + # Generate deployment request + echo "Generating deployment request..." + cat < "$RECORD_FILE" record: type: ApplicationDeploymentRequest version: '1.0.0' @@ -124,4 +134,4 @@ fi # Cleanup rm -f $RECORD_FILE $CONFIG_FILE -echo "Script completed successfully" +echo "Script completed successfully" \ No newline at end of file