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
74 changes: 74 additions & 0 deletions .github/scripts/deploy-contracts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash
set -e

# ./.github/scripts/deploy-contracts.sh
# Meticulously build and deploy Soroban contracts to Stellar Testnet.

NETWORK="testnet"
RPC_URL="https://soroban-testnet.stellar.org"
FRIENDLY_NAME="deployer"

echo "🛠️ Building optimized WASM binaries..."
cargo build --target wasm32-unknown-unknown --release -p escrow -p reputation -p job_registry

# Create scripts directory if not exists (redundant for CI but good for local)
mkdir -p ./.github/scripts

# Function to deploy a contract and capture its address
deploy_contract() {
local contract_name=$1
local wasm_path="./target/wasm32-unknown-unknown/release/${contract_name}.wasm"

echo "🚀 Deploying ${contract_name} to ${NETWORK}..."

# In a real CI, STELLAR_ACCOUNT_SECRET would be provided
# stellar contract deploy \
# --wasm "$wasm_path" \
# --source "$FRIENDLY_NAME" \
# --network "$NETWORK"

# For now, we simulation the output or use the CLI if available
# Assuming the CLI is available in the CI environment
ID=$(stellar contract deploy \
--wasm "$wasm_path" \
--source-account "$STELLAR_ACCOUNT_SECRET" \
--network "$NETWORK" \
--rpc-url "$RPC_URL")

echo "$ID"
}

# Ensure .env.local exists or create it
ENV_FILE=".env.local"
touch $ENV_FILE

echo "📦 Capturing Contract IDs..."

ESCROW_ID=$(deploy_contract "escrow")
REPUTATION_ID=$(deploy_contract "reputation")
JOB_REGISTRY_ID=$(deploy_contract "job_registry")

# Update .env.local with new IDs
sed -i "/NEXT_PUBLIC_ESCROW_CONTRACT_ID=/d" $ENV_FILE
echo "NEXT_PUBLIC_ESCROW_CONTRACT_ID=$ESCROW_ID" >> $ENV_FILE

sed -i "/NEXT_PUBLIC_REPUTATION_CONTRACT_ID=/d" $ENV_FILE
echo "NEXT_PUBLIC_REPUTATION_CONTRACT_ID=$REPUTATION_ID" >> $ENV_FILE

sed -i "/NEXT_PUBLIC_JOB_REGISTRY_CONTRACT_ID=/d" $ENV_FILE
echo "NEXT_PUBLIC_JOB_REGISTRY_CONTRACT_ID=$JOB_REGISTRY_ID" >> $ENV_FILE

echo "✅ Deployment complete! IDs saved to $ENV_FILE"
echo "Escrow: $ESCROW_ID"
echo "Reputation: $REPUTATION_ID"
echo "Job Registry: $JOB_REGISTRY_ID"

# Optional: Notify via GitHub Step Summary or similar
if [ -n "$GITHUB_STEP_SUMMARY" ]; then
echo "### 🚀 Deployment Successful" >> $GITHUB_STEP_SUMMARY
echo "| Contract | ID |" >> $GITHUB_STEP_SUMMARY
echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
echo "| Escrow | \`$ESCROW_ID\` |" >> $GITHUB_STEP_SUMMARY
echo "| Reputation | \`$REPUTATION_ID\` |" >> $GITHUB_STEP_SUMMARY
echo "| Job Registry | \`$JOB_REGISTRY_ID\` |" >> $GITHUB_STEP_SUMMARY
fi
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,32 @@ jobs:
- run: npx playwright install --with-deps
- run: npm run build --prefix apps/web
- run: npm run test:e2e

# ── Deployment ──────────────────────────────────────────────────────────────
deploy:
name: Deploy to Testnet
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/development'
needs: [contracts-test, backend-test, e2e]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Install Stellar CLI
run: |
cargo install --locked stellar-cli --version 21.6.0
- name: Deploy Contracts
env:
STELLAR_ACCOUNT_SECRET: ${{ secrets.STELLAR_ACCOUNT_SECRET }}
run: |
./.github/scripts/deploy-contracts.sh
- name: Deploy Backend
run: |
echo "🚀 Backend deployment logic (Fly.io/etc)..."
# fly deploy --prefix backend
- name: Deploy Frontend
run: |
echo "🚀 Frontend deployment logic (Vercel/etc)..."
# vercel deploy --prefix apps/web --prod

Loading