Update deploy.sh
Some checks failed
Check Latest Release / deploy (push) Failing after 33s
Deploy from Main / deploy (push) Successful in 1m0s

This commit is contained in:
zramsay 2025-11-19 21:44:09 +00:00
parent 76a23b065c
commit e5a77b6930

View File

@ -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 <owner/repo> <tag>"
echo "Usage: $0 <owner/repo> <branch-or-tag>"
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 <<EOF | sed '/.*: ""$/d' > "$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 <<EOF | sed '/.*: ""$/d' > "$RECORD_FILE"
# Generate deployment request
echo "Generating deployment request..."
cat <<EOF | sed '/.*: ""$/d' > "$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"