Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 🤖 service deployment via runner (initial) #71

Draft
wants to merge 73 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
c3dab6c
chore: 🤖 dfx identity script which handles the secret identity
heldrida Mar 28, 2022
ce47182
chore: 🤖 add identity detail in the id script
heldrida Mar 28, 2022
7b6934c
chore: 🤖 display principal in dfx identity script
heldrida Mar 28, 2022
82e193c
chore: 🤖 add pre-built ic cdk optimizer bin
heldrida Mar 28, 2022
9a6c5ea
chore: 🤖 services deploy workflow (base)
heldrida Mar 28, 2022
acb96dd
chore: 🤖 temporary branch in workflow for dev
heldrida Mar 28, 2022
f513bb3
chore: 🤖 disable type closed and if github ref
heldrida Mar 28, 2022
d85537c
chore: 🤖 add PAT token to workflow for submodules init
heldrida Mar 28, 2022
aa31f3f
chore: 🤖 pem file and remove sed
heldrida Mar 28, 2022
dbf850a
chore: 🤖 path amends to dfx identity script
heldrida Mar 28, 2022
b1fc322
chore: 🤖 pass dfx identity secret to script
heldrida Mar 28, 2022
51f1861
chore: 🤖 throw exit 1, identity not found
heldrida Mar 28, 2022
84e1398
chore: 🤖 deploy services script
heldrida Mar 29, 2022
ff575a3
chore: 🤖 add services deploy to workflow
heldrida Mar 29, 2022
c8c1521
chore: 🤖 debug TIAS workdir
heldrida Mar 29, 2022
b0d8dd5
chore: 🤖 debug TIAS workdir pt2
heldrida Mar 29, 2022
83a8c22
chore: 🤖 point to latest on nft-marketplace, replaced to dfx.json fle…
heldrida Mar 29, 2022
f0dc543
chore: 🤖 call create before install
heldrida Mar 29, 2022
51d68ed
chore: 🤖 TIAS deploy
heldrida Mar 29, 2022
a249a54
chore: 🤖 remove -m
heldrida Mar 29, 2022
c49c1a7
chore: 🤖 point to latest which remove ephemeral and adds canister ids…
heldrida Mar 29, 2022
e55784c
chore: 🤖 TIAS dfx canister create and install
heldrida Mar 30, 2022
5e709aa
chore: 🤖 point to latest cap which has canister ids
heldrida Mar 30, 2022
7006fb3
chore: 🤖 should deploy cap to mainnet, not fleek testnet
heldrida Mar 30, 2022
c717ebf
chore: 🤖 should deploy crowns to mainnet, not fleek testnet
heldrida Mar 30, 2022
8df7bce
chore: 🤖 should only deploy marketplace and cap for stg
heldrida Mar 30, 2022
afc88b6
chore: 🤖 TIAS get wallet and account id
heldrida Mar 30, 2022
1280265
chore: 🤖 TIAS remove wallet
heldrida Mar 30, 2022
fba510c
chore: 🤖 TIAS use wallet
heldrida Mar 30, 2022
9088fec
chore: 🤖 TIAS after cycles topup
heldrida Mar 30, 2022
393919b
chore: 🤖 use latest nft-marketplace with opt cdk
heldrida Mar 30, 2022
9c68914
chore: 🤖 use cap staging which is pinned in cap channel
heldrida Mar 30, 2022
ea31dbb
chore: 🤖 pass cap for marketplace init
heldrida Mar 30, 2022
ef8abcc
chore: 🤖 enable wicp
heldrida Mar 30, 2022
09d0fbe
chore: 🤖 deploy wicp use correct network
heldrida Mar 30, 2022
62fb424
chore: 🤖 point to latest nft-marketplace
heldrida Mar 30, 2022
6320f32
chore: 🤖 update deploy script to use mainnet staging and update fe en…
heldrida Mar 30, 2022
dcacb3f
chore: 🤖 notes
heldrida Apr 11, 2022
58bf6e7
chore: 🤖 dfx identity script which handles the secret identity
heldrida Mar 28, 2022
0cf0150
chore: 🤖 add identity detail in the id script
heldrida Mar 28, 2022
3509c55
chore: 🤖 display principal in dfx identity script
heldrida Mar 28, 2022
f3397d0
chore: 🤖 add pre-built ic cdk optimizer bin
heldrida Mar 28, 2022
f547613
chore: 🤖 services deploy workflow (base)
heldrida Mar 28, 2022
65163d7
chore: 🤖 temporary branch in workflow for dev
heldrida Mar 28, 2022
9b01122
chore: 🤖 disable type closed and if github ref
heldrida Mar 28, 2022
49e4172
chore: 🤖 add PAT token to workflow for submodules init
heldrida Mar 28, 2022
bfadbf6
chore: 🤖 pem file and remove sed
heldrida Mar 28, 2022
4349a7d
chore: 🤖 path amends to dfx identity script
heldrida Mar 28, 2022
f39624d
chore: 🤖 pass dfx identity secret to script
heldrida Mar 28, 2022
a2d825a
chore: 🤖 throw exit 1, identity not found
heldrida Mar 28, 2022
0c27111
chore: 🤖 deploy services script
heldrida Mar 29, 2022
f83dff7
chore: 🤖 add services deploy to workflow
heldrida Mar 29, 2022
b14d9cf
chore: 🤖 debug TIAS workdir
heldrida Mar 29, 2022
5989c3f
chore: 🤖 debug TIAS workdir pt2
heldrida Mar 29, 2022
30aeb8d
chore: 🤖 call create before install
heldrida Mar 29, 2022
ca91b3d
chore: 🤖 TIAS deploy
heldrida Mar 29, 2022
cf2136f
chore: 🤖 remove -m
heldrida Mar 29, 2022
7c63175
chore: 🤖 TIAS dfx canister create and install
heldrida Mar 30, 2022
0708740
chore: 🤖 point to latest cap which has canister ids
heldrida Mar 30, 2022
cc92395
chore: 🤖 should deploy cap to mainnet, not fleek testnet
heldrida Mar 30, 2022
74ffe5c
chore: 🤖 should deploy crowns to mainnet, not fleek testnet
heldrida Mar 30, 2022
b503f31
chore: 🤖 should only deploy marketplace and cap for stg
heldrida Mar 30, 2022
a0018a8
chore: 🤖 TIAS get wallet and account id
heldrida Mar 30, 2022
47bee55
chore: 🤖 TIAS remove wallet
heldrida Mar 30, 2022
651bb45
chore: 🤖 TIAS use wallet
heldrida Mar 30, 2022
792c31d
chore: 🤖 TIAS after cycles topup
heldrida Mar 30, 2022
77f61cc
chore: 🤖 use cap staging which is pinned in cap channel
heldrida Mar 30, 2022
b0f5d9d
chore: 🤖 pass cap for marketplace init
heldrida Mar 30, 2022
5836e4b
chore: 🤖 enable wicp
heldrida Mar 30, 2022
e716b19
chore: 🤖 deploy wicp use correct network
heldrida Mar 30, 2022
d6aa909
chore: 🤖 update deploy script to use mainnet staging and update fe en…
heldrida Mar 30, 2022
85070d3
chore: 🤖 notes
heldrida Apr 11, 2022
20db965
Merge branch 'chore/services-deployment-initial' of github.com:Psyche…
ozwaldorf Apr 19, 2022
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
Binary file not shown.
88 changes: 88 additions & 0 deletions .github/workflows/services-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Services deploy

on:
pull_request:
# TODO: This related to *1 (should be enabled after manual tests)
# types: [closed]
branches:
- staging
# TODO: Remove temporary branch used during dev
- chore/services-deployment-initial
push:
branches:
- staging
# TODO: Remove temporary branch used during dev
- chore/services-deployment-initial

workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
# TODO: This related to *1 (should be enabled after manual tests)
# if: github.ref == 'refs/heads/staging'
env:
CI: 1
DEBUG: 0
DFX_VERSION: 0.9.2
DFX_WARNING: -version_check
NODE_ENV: ci
DFX_CANDID_RELEASE: 2022-01-06
DEPLOY_TARGET: staging

steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
token: ${{ secrets.PAT }}

- name: Cache Rust
uses: actions/cache@v2
id: cache-rust
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Setup toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
default: true
override: true
target: wasm32-unknown-unknown

- name: Adds ic-cdk-optimizer
run: |
cd ./.bin/stable-x86_64-unknown-linux-gnu
gzip -d ic-cdk-optimizer.gz
cp ic-cdk-optimizer /usr/local/bin

- name: Cache Dfx
id: cache-dfx
uses: actions/cache@v2
with:
path: |
/usr/local/bin/dfx
key: cache-dfx-${{ hashFiles('nft-marketplace/dfx.json') }}

- name: Install DFX
if: steps.cache-dfx.outputs.cache-hit != 'true'
run: |
yes Y | DFX_VERSION="$DFX_VERSION" sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"

- name: Setup DFX Identity
run: |
.scripts/deploy/dfx-identity.sh
env:
DFX_IDENTITY: ${{ secrets.DFX_IDENTITY }}

- name: Deploy Services
run: |
.scripts/deploy/deploy-services.sh
115 changes: 115 additions & 0 deletions .scripts/deploy/deploy-services.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#!/bin/bash

set -x

cd "$(dirname $BASH_SOURCE)" && cd ../../nft-marketplace || exit 1

printf "🤖 Deploy Services for env (%s)\n\n" "$DEPLOY_TARGET"

# Cap staging (deployed for nft-marketplace-fe)
# cap="q4lzc-5qaaa-aaaal-qaueq-cai"
# Cap staging (pinned in the cap-ooo discord channel)
# pending request on controllers update
# https://discord.com/channels/837010835423494144/887363387909079062/958771177755672606
cap="e22n6-waaaa-aaaah-qcd2q-cai"
# Crowns staging
crowns="iqvo2-7qaaa-aaaam-qacxa-cai"
marketplace="surgh-pqaaa-aaaal-qauiq-cai"
wicp="s5sn3-zyaaa-aaaal-qauja-cai"
owner=$(dfx identity get-principal)
network="ic"
wallet="rwe3y-7aaaa-aaaal-qaudq-cai"

dfx identity --network ic set-wallet "$wallet"

deployCap()
{
printf "🤖 Deploy Cap\n"

(
cd ./cap || exit 1

dfx deploy --network "$network" \
--argument '(null)' \
ic-history-router
)
}

deployCrowns()
{
printf "🤖 Deploy Crowns\n"

(
cd ./crowns || exit 1

tokenName="Crowns"
tokenSymbol="CRW"

dfx deploy --network "$network" \
--argument "(
opt record {
name = opt \"$tokenName\";
logo = opt \"data:image/jpeg;base64,...\";
symbol = opt \"$tokenSymbol\";
owners = opt vec { principal \"$owner\" };
}
)" \
crowns
)
}

deployDab()
{
printf "🤖 Deploy Dab [SKIP]\n"
}

deployMarketplace()
{
printf "🤖 Deploy Marketplace\n"

(
dfx deploy --network "$network" \
--argument "(
principal \"$cap\",
principal \"$owner\"
)" \
marketplace
)
}

deployWICP()
{
printf "🤖 Deploy wICP\n"

(
cd ./wicp || exit 1

amount=1000000000000

dfx deploy \
--network "$network" \
wicp --argument="(
\"data:image/jpeg;base64,$(base64 ../.repo/images/logo-of-wicp.png)\",
\"wicp\",
\"WICP\",
8:nat8,
$amount:nat,
principal \"$owner\",
0,
principal \"$owner\",
principal \"$cap\"
)"
)
}

if [[ "$DEPLOY_TARGET" == "staging" ]];
then
# TODO: Check the notes in https://github.com/Psychedelic/nft-marketplace-fe/pull/71
# Some canisters are already deployed like Cap or Crowns...
# deployCap
# deployCrowns
# deployDab

deployMarketplace
deployWICP
fi;
33 changes: 33 additions & 0 deletions .scripts/deploy/dfx-identity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# The system identity is
# bewg6-izdus-bfibk-qh2d2-gj6kw-jk5pw-ll6fu-t2g2w-fdki2-bxukw-xae
# which secret is set in
# https://github.com/Psychedelic/nft-marketplace-fe/settings/secrets/actions

printf "🕵🏻‍♀️ Create the DFX Identity\n\n"

defaultIdentityDir=~/.config/dfx/identity/default
pemFilename=identity.pem

printf "Create the default identity directory (%s)\n" "$defaultIdentityDir"

mkdir -p "$defaultIdentityDir"

touch "$defaultIdentityDir"/"$pemFilename"

printf "Create the PEM from environment secret\n"

echo "$DFX_IDENTITY" > "$defaultIdentityDir"/"$pemFilename"

defaultIdentity=$(dfx identity get-principal)

if [[ -z "$defaultIdentity" ]];
then
printf "👺 Oops! Identity was not set.\n"

exit 1
fi

printf "Done 👍 DFX identity created!\n"
printf "The identity is %s\n\n" "$defaultIdentity"
17 changes: 9 additions & 8 deletions src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ type NodeEnv = 'development' | 'production' | 'test';
// eslint-disable-next-line operator-linebreak
const env: NodeEnv =
// eslint-disable-next-line operator-linebreak
(process.env.REACT_APP_NODE_ENV as unknown as NodeEnv) ||
'development';
(process.env.REACT_APP_NODE_ENV as unknown as NodeEnv) || 'development';

// The Crowns DIP-721 v2, canister ids are available in:
// https://github.com/Psychedelic/crowns/blob/main/canister_ids.json
Expand Down Expand Up @@ -50,17 +49,18 @@ const config: Config = {
},
staging: {
// TODO: this should be removed or have a none ambiguous name
canisterId: 'rkp4c-7iaaa-aaaaa-aaaca-cai',
host: 'https://testnet.psychedelic.ooo',
canisterId: 'iqvo2-7qaaa-aaaam-qacxa-cai',
host: 'https://mainnet.dfinity.network',
// host: 'ic0.app',
// TODO: See <Important-1>
// TODO: This is causing confusion, as we have a fieldname for crowns canister id
// can we get rid of collectionId?
collectionId: '5hzni-qqaaa-aaaaa-aaboq-cai',
collectionId: 'iqvo2-7qaaa-aaaam-qacxa-cai',
kyasshuMarketplaceAPI: 'https://kyasshu-dev.fleek.co',
icExplorer: 'https://dashboard.internetcomputer.org',
crownsCanisterId: '5hzni-qqaaa-aaaaa-aaboq-cai',
marketplaceCanisterId: 'yva2f-aiaaa-aaaaa-aabqa-cai',
wICPCanisterId: 'y4drz-waaaa-aaaaa-aabrq-cai',
crownsCanisterId: 'iqvo2-7qaaa-aaaam-qacxa-cai',
marketplaceCanisterId: 'surgh-pqaaa-aaaal-qauiq-cai',
wICPCanisterId: 's5sn3-zyaaa-aaaal-qauja-cai',
},
development: {
// TODO: this should be removed or have a none ambiguous name
Expand Down Expand Up @@ -96,3 +96,4 @@ export default config[env];

// eslint-disable-next-line no-console
console.log(`Config ENV=${env}:`, config[env]);