Skip to content

Commit

Permalink
chore: update Gitlab CI actions, add handy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kinwo committed Apr 7, 2024
1 parent 72c4726 commit 3f0b9c8
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 87 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
BEAMFI_PRINCIPAL: ${{ secrets.BEAMFI_PRINCIPAL }}
BILLING_KEY: ${{ secrets.BILLING_KEY }}
BATTERY_API_KEY: ${{ secrets.BATTERY_API_KEY }}
BATTERY_PRINCIAL: ${{ secrets.BATTERY_PRINCIAL }}
- name: Debug URL
run: echo https://completedeploy-4gbndkvjta-uc.a.run.app?apiKey=${{ secrets.FB_API_KEY }}&canisterId=${{ steps.provision.outputs.controller_principal }}
- name: Call Firebase Function /complete_deploy and assert HTTP status 200
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/local-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ jobs:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
BEAMFI_PRINCIPAL: ${{ secrets.BEAMFI_PRINCIPAL }}
BILLING_KEY: ${{ secrets.BILLING_KEY }}
BATTERY_API_KEY: ${{ secrets.BATTERY_API_KEY }}
BATTERY_PRINCIAL: ${{ secrets.BATTERY_PRINCIAL }}
- name: Show Controller Principal
run: echo ${{ steps.provision.outputs.controller_principal }}
11 changes: 9 additions & 2 deletions scripts/deploy_controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@ if [[ -z "${BILLING_KEY}" ]]; then
exit 1
fi

if [[ -z "${BATTERY_API_KEY}" ]]; then
echo "BATTERY_API_KEY is unset."
exit 1
fi

# To deplopy locally, update IC_NETWORK to local. To deploy to ic, update IC_NETWORK to ic.
IC_NETWORK=${IC_NETWORK:-local}

BRAIN_PRINCIPAL=$(dfx canister --network $IC_NETWORK id arcmindai_brain)
TOOLS_PRINCIPAL=$(dfx canister --network $IC_NETWORK id arcmindai_tools)
BATTERY_PRINCIAL=$(dfx canister --network $IC_NETWORK id cycles_battery)

BROWSE_WEBSITE_GPT_MODEL=gpt-3.5-turbo-1106

# Deploy controller canister
echo Deploying controller canister with owner=$OWNER_PRINCIPAL, brain=$BRAIN_PRINCIPAL, browse_website_gpt_model=$BROWSE_WEBSITE_GPT_MODEL, tools=$TOOLS_PRINCIPAL, VECTOR_PRINCIPAL=$VECTOR_PRINCIPAL, BEAMFI_PRINCIPAL=$BEAMFI_PRINCIPAL, BILLING_KEY=$BILLING_KEY on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_controller --argument "(opt principal \"$OWNER_PRINCIPAL\", opt principal \"$BRAIN_PRINCIPAL\", opt principal \"$TOOLS_PRINCIPAL\", opt principal \"$VECTOR_PRINCIPAL\", opt principal \"$BEAMFI_PRINCIPAL\", opt \"$BROWSE_WEBSITE_GPT_MODEL\", opt \"$BILLING_KEY\")"
echo Deploying controller canister with owner=$OWNER_PRINCIPAL, brain=$BRAIN_PRINCIPAL, browse_website_gpt_model=$BROWSE_WEBSITE_GPT_MODEL, tools=$TOOLS_PRINCIPAL, VECTOR_PRINCIPAL=$VECTOR_PRINCIPAL, BEAMFI_PRINCIPAL=$BEAMFI_PRINCIPAL, BATTERY_PRINCIAL=$BATTERY_PRINCIAL, BILLING_KEY=$BILLING_KEY, BATTERY_API_KEY=$BATTERY_API_KEY on $IC_NETWORK
dfx deploy --network $IC_NETWORK --mode reinstall arcmindai_controller --argument "(opt principal \"$OWNER_PRINCIPAL\", opt principal \"$BRAIN_PRINCIPAL\", opt principal \"$TOOLS_PRINCIPAL\", opt principal \"$VECTOR_PRINCIPAL\", opt principal \"$BEAMFI_PRINCIPAL\", opt principal \"$BATTERY_PRINCIAL\", opt \"$BROWSE_WEBSITE_GPT_MODEL\", opt \"$BILLING_KEY\", opt \"$BATTERY_API_KEY\")"
10 changes: 9 additions & 1 deletion scripts/ledger_sample.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ Account ID of principal o5uxz-byaaa-aaaah-adnyq-cai:


Please stream 0.01 ICP tokens to principal ID evdxs-el2wl-mrpaf-ehe75-uwoax-mqoc6-e55si-ls4va-gyecy-ywbio-bae
Please stream 0.01 ICP tokens to principal ID hpikg-6exdt-jn33w-ndty3-fc7jc-tl2lr-buih3-cs3y7-tftkp-sfp62-gqe


Please stream 0.01 ICP tokens to principal ID hpikg-6exdt-jn33w-ndty3-fc7jc-tl2lr-buih3-cs3y7-tftkp-sfp62-gqe
# Demo
# 1 ICP = 100_000_000
# 0.07731000 ICP = 7_731_000
# 0.05 = 5_000_000
dfx canister --network ic call nns-ledger icrc1_balance_of "(record {owner = principal \"wcz6z-niaaa-aaaah-adxzq-cai\"; })"
dfx canister --network ic call nns-ledger icrc1_transfer "(record { to = record { owner = principal \"wcz6z-niaaa-aaaah-adxzq-cai\";}; amount = 5_000_000;})"

# Please stream 0.01 ICP tokens to principal ID evdxs-el2wl-mrpaf-ehe75-uwoax-mqoc6-e55si-ls4va-gyecy-ywbio-bae
14 changes: 12 additions & 2 deletions scripts/provision-instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ if [[ -z "${BILLING_KEY}" ]]; then
exit 1
fi

if [[ -z "${BATTERY_API_KEY}" ]]; then
echo "BATTERY_API_KEY is unset."
exit 1
fi

if [[ -z "${BATTERY_PRINCIAL}" ]]; then
echo "BATTERY_PRINCIAL is unset."
exit 1
fi

GPT_MODEL=gpt-4
BROWSE_WEBSITE_GPT_MODEL=gpt-3.5-turbo-1106

Expand Down Expand Up @@ -72,8 +82,8 @@ dfx canister --network $IC_NETWORK call arcmindai_tools get_owner
TOOLS_PRINCIPAL=$(dfx canister --network $IC_NETWORK id arcmindai_tools)

# Deploy controller canister
echo Deploying controller canister with owner $OWNER_PRINCIPAL, brain $BRAIN_PRINCIPAL, tools $TOOLS_PRINCIPAL, vector $VECTOR_PRINCIPAL, beamfi $BEAMFI_PRINCIPAL, browse_website_gpt_model $BROWSE_WEBSITE_GPT_MODEL, billing_key $BILLING_KEY on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_controller --argument "(opt principal \"$OWNER_PRINCIPAL\", opt principal \"$BRAIN_PRINCIPAL\", opt principal \"$TOOLS_PRINCIPAL\", opt principal \"$VECTOR_PRINCIPAL\", opt principal \"$BEAMFI_PRINCIPAL\", opt \"$BROWSE_WEBSITE_GPT_MODEL\", opt \"$BILLING_KEY\")"
echo Deploying controller canister with owner=$OWNER_PRINCIPAL, brain=$BRAIN_PRINCIPAL, browse_website_gpt_model=$BROWSE_WEBSITE_GPT_MODEL, tools=$TOOLS_PRINCIPAL, VECTOR_PRINCIPAL=$VECTOR_PRINCIPAL, BEAMFI_PRINCIPAL=$BEAMFI_PRINCIPAL, BATTERY_PRINCIAL=$BATTERY_PRINCIAL, BILLING_KEY=$BILLING_KEY, BATTERY_API_KEY=$BATTERY_API_KEY on $IC_NETWORK
dfx deploy --network $IC_NETWORK arcmindai_controller --argument "(opt principal \"$OWNER_PRINCIPAL\", opt principal \"$BRAIN_PRINCIPAL\", opt principal \"$TOOLS_PRINCIPAL\", opt principal \"$VECTOR_PRINCIPAL\", opt principal \"$BEAMFI_PRINCIPAL\", opt principal \"$BATTERY_PRINCIAL\", opt \"$BROWSE_WEBSITE_GPT_MODEL\", opt \"$BILLING_KEY\", opt \"$BATTERY_API_KEY\")"

echo Controller Owner:
dfx canister --network $IC_NETWORK call arcmindai_controller get_owner
Expand Down
82 changes: 0 additions & 82 deletions scripts/provision.sh

This file was deleted.

16 changes: 16 additions & 0 deletions scripts/topup-canisters.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# To deplopy locally, update IC_NETWORK to local. To deploy to ic, update IC_NETWORK to ic.
IC_NETWORK=${IC_NETWORK:-local}

# Validate required env vars
if [[ -z "${CYCLES_BATTERY_API_KEY}" ]]; then
echo "CYCLES_BATTERY_API_KEY is unset."
exit 1
fi

GROUP_NAME="test"
REQ_CYCLES_AMOUNT=1000000
CYCLES_BALANCE=3100000000000


echo Calling cycles battery canister with GROUP_NAME=$GROUP_NAME CYCLES_BATTERY_API_KEY=$CYCLES_BATTERY_API_KEY, REQ_CYCLES_AMOUNT=$REQ_CYCLES_AMOUNT, CYCLES_BALANCE=$CYCLES_BALANCE on $IC_NETWORK
dfx canister --network $IC_NETWORK call cycles_battery topup_cycles "(\"$GROUP_NAME\", \"$CYCLES_BATTERY_API_KEY\", $REQ_CYCLES_AMOUNT, $CYCLES_BALANCE)"

0 comments on commit 3f0b9c8

Please sign in to comment.