Skip to content
Open
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
35 changes: 16 additions & 19 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,43 +34,40 @@ jobs:
with:
node-version: 18

- name: Install DFX
uses: dfinity/setup-dfx@main
with:
dfx-version: 0.29.2
- name: Install ICP-CLI
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/dfinity/icp-cli/releases/download/v0.1.0-beta.6/icp-cli-installer.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- name: Dump Identity
- name: Setup Identity
run: |
mkdir -p ~/.config/dfx/identity/default
echo $DFX_IDENTITY_DESIGN_TEAM | base64 -d > ~/.config/dfx/identity/default/identity.pem
sed -i 's/\\r\\n/\r\n/g' ~/.config/dfx/identity/default/identity.pem
mkdir -p ~/.local/share/icp-cli/identity/keys
echo $ICP_IDENTITY_PORTAL_DEPLOY | base64 -d > ~/.local/share/icp-cli/identity/keys/portal-deploy.pem
sed -i 's/\\r\\n/\r\n/g' ~/.local/share/icp-cli/identity/keys/portal-deploy.pem
icp identity import portal-deploy --from-pem ~/.local/share/icp-cli/identity/keys/portal-deploy.pem --storage plaintext
icp identity default portal-deploy
env:
DFX_IDENTITY_DESIGN_TEAM: ${{ secrets.DFX_IDENTITY_DESIGN_TEAM }}
ICP_IDENTITY_PORTAL_DEPLOY: ${{ secrets.DFX_IDENTITY_DESIGN_TEAM }}

- name: Check Canister Balance
run: |
balance=$(dfx canister --network ic status portal 2>&1 >/dev/null | grep Balance: | sed 's/[^0-9]//g')
balance=$(icp canister status portal -e ic 2>&1 >/dev/null | grep Balance: | sed 's/[^0-9]//g')
LANG=en_US.UTF-8
balance_formatted=$(echo $balance | awk '{printf "%'\''d\n", $0}')
echo "Canister balance: $balance_formatted"
if [ "5000000000000" -gt "$balance" ]; then
canister_id=$(cat "$GITHUB_WORKSPACE/canister_ids.json" | jq -r '.portal.ic')
template="{ \"channel\": \"C04EGHHU9U2\", \"blocks\": [ { \"type\": \"section\", \"text\": { \"type\": \"mrkdwn\", \"text\": \"@channel internetcomputer.org canister \`$canister_id\` balance is \`$balance_formatted\`.\n\nTop it up by\n- running \`dfx ledger --network ic top-up $canister_id --amount 5.0\`\n- or by adding the canister on the NNS and sending cycles to it.\" } } ]}"
canister_id=$(cat "$GITHUB_WORKSPACE/.icp/data/mappings/ic.ids.json" | jq -r '.portal')
template="{ \"channel\": \"C04EGHHU9U2\", \"blocks\": [ { \"type\": \"section\", \"text\": { \"type\": \"mrkdwn\", \"text\": \"@channel internetcomputer.org canister \`$canister_id\` balance is \`$balance_formatted\`.\n\nTop it up by\n- running \`icp canister top-up $canister_id --amount 5t -e ic\`\n- or by adding the canister on the NNS and sending cycles to it.\" } } ]}"
curl --data "$template" -H "Content-type: application/json" -H "Authorization: Bearer $SLACK_TOKEN" -X POST https://slack.com/api/chat.postMessage -o /dev/null
fi
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}

- name: Install Dependencies
run: npm install

- name: Deploy to Mainnet
run: dfx deploy --network=ic --no-wallet portal --verbose --yes
env:
DFX_WARNING: -mainnet_plaintext_identity
run: icp deploy portal -e ic

- name: Get URL
id: get-url
run: |
URL="https://$(cat "$GITHUB_WORKSPACE/canister_ids.json" | jq -r '.portal.ic').icp0.io"
URL="https://$(cat "$GITHUB_WORKSPACE/.icp/data/mappings/ic.ids.json" | jq -r '.portal').icp0.io"
echo "url=$URL" >> $GITHUB_OUTPUT
2 changes: 1 addition & 1 deletion .github/workflows/pr-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
pip install ic-py
python3 .github/workflows/scripts/release-canister.py $pull_number
env:
DFX_IDENTITY_PREVIEW: ${{ secrets.DFX_IDENTITY_PREVIEW }}
ICP_IDENTITY_PREVIEW: ${{ secrets.DFX_IDENTITY_PREVIEW }}
POOL_CANISTER_ID: ${{ secrets.POOL_CANISTER_ID }}

- uses: actions/github-script@v6
Expand Down
56 changes: 15 additions & 41 deletions .github/workflows/preview-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,64 +33,38 @@ jobs:
with:
python-version: "3.10"

- name: Install DFX
uses: dfinity/setup-dfx@main
with:
dfx-version: 0.29.2

- name: Cache icx-asset binary
id: cache-icx-asset-bin
uses: actions/cache@v3
with:
path: sdk/target/release/icx-asset
key: icxassetbin-master
restore-keys: |
icxassetbin-

- name: Install icx-asset
if: steps.cache-icx-asset-bin.outputs.cache-hit != 'true'
run: |
rm -rf sdk
git clone --depth 1 https://github.com/dfinity/sdk.git
cd sdk
cargo build -p icx-asset --release

- name: Add icx-asset to path
- name: Install ICP-CLI
run: |
echo "`pwd`/sdk/target/release/" >> $GITHUB_PATH
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/dfinity/icp-cli/releases/download/v0.1.0-beta.6/icp-cli-installer.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- name: "Build & Deploy"
run: |
mkdir -p ~/.config/dfx/identity/default

echo $DFX_IDENTITY_PREVIEW | base64 -d > ~/.config/dfx/identity/default/identity.pem
sed -i 's/\\r\\n/\r\n/g' ~/.config/dfx/identity/default/identity.pem
# Setup identity
mkdir -p ~/.local/share/icp-cli/identity/keys
echo $ICP_IDENTITY_PREVIEW | base64 -d > ~/.local/share/icp-cli/identity/keys/preview-deploy.pem
sed -i 's/\\r\\n/\r\n/g' ~/.local/share/icp-cli/identity/keys/preview-deploy.pem
icp identity import preview-deploy --from-pem ~/.local/share/icp-cli/identity/keys/preview-deploy.pem --storage plaintext
icp identity default preview-deploy

# request preview canister from the pool
pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
pip install ic-py
canister_id=$(python3 .github/workflows/scripts/request-canister.py $pull_number)

# overwrite canister id in dfx.json
echo "{\"portal\":{\"ic\":\"$canister_id\"}}" > canister_ids.json
# Create icp-cli canister ID mapping for ic environment
mkdir -p .icp/data/mappings
echo "{\"portal\":\"$canister_id\"}" > .icp/data/mappings/ic.ids.json

echo "PREVIEW_CANISTER_ID=$canister_id" >> $GITHUB_ENV

# install and deploy
# Deploy the canister (recipe handles build steps)
git submodule update --init
time npm install

export PREVIEW_CANISTER_ID=$canister_id

dfx canister --network ic create --all
time dfx build --network ic portal
dfx canister --network ic install portal --mode=reinstall --yes --wasm .dfx/ic/canisters/portal/assetstorage.wasm.gz || true

time icx-asset --replica https://icp0.io --pem ~/.config/dfx/identity/default/identity.pem sync $canister_id build
time icp deploy portal -e ic --mode reinstall

env:
DFX_IDENTITY_PREVIEW: ${{ secrets.DFX_IDENTITY_PREVIEW }}
DFX_WARNING: -mainnet_plaintext_identity
ICP_IDENTITY_PREVIEW: ${{ secrets.DFX_IDENTITY_PREVIEW }}
POOL_CANISTER_ID: ${{ secrets.POOL_CANISTER_ID }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Interact with preview canister pool: https://github.com/dfinity/preview-canister-pool
#

private_key = base64.b64decode(os.environ["DFX_IDENTITY_PREVIEW"]).decode("utf-8")
private_key = base64.b64decode(os.environ["ICP_IDENTITY_PREVIEW"]).decode("utf-8")
pool_id = os.environ["POOL_CANISTER_ID"]

identity = Identity.from_pem(private_key)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/release-canister.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
print("Usage: python3 release-canister.py <ref>")
exit(1)

for v in ["DFX_IDENTITY_PREVIEW","POOL_CANISTER_ID"]:
for v in ["ICP_IDENTITY_PREVIEW","POOL_CANISTER_ID"]:
if not v in os.environ:
print(f"release-canister.py: {v} env variable missing")
exit(1)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/request-canister.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
print("Usage: python3 request_canister.py <ref>")
exit(1)

for v in ["DFX_IDENTITY_PREVIEW","POOL_CANISTER_ID"]:
for v in ["ICP_IDENTITY_PREVIEW","POOL_CANISTER_ID"]:
if not v in os.environ:
print(f"request-canister.py: {v} env variable missing")
exit(1)
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/update-search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Dump Identity
- name: Setup Identity
run: |
mkdir -p ~/.config/dfx/identity/default
echo $DFX_IDENTITY_PREVIEW | base64 -d > ~/.config/dfx/identity/default/identity.pem
mkdir -p ~/.local/share/icp-cli/identity/keys
echo $ICP_IDENTITY_PREVIEW | base64 -d > ~/.local/share/icp-cli/identity/keys/search-updater.pem
sed -i 's/\\r\\n/\r\n/g' ~/.local/share/icp-cli/identity/keys/search-updater.pem
env:
DFX_IDENTITY_PREVIEW: ${{ secrets.DFX_IDENTITY_PREVIEW }}
ICP_IDENTITY_PREVIEW: ${{ secrets.DFX_IDENTITY_PREVIEW }}

- name: Build website
run: |
Expand All @@ -39,4 +40,4 @@ jobs:
cd search

cargo run --release --bin search-cli -- index ../docs.json stopwords.txt output.json
cargo run --release --bin search-cli -- upload output.json stopwords.txt 5qden-jqaaa-aaaam-abfpa-cai ~/.config/dfx/identity/default/identity.pem
cargo run --release --bin search-cli -- upload output.json stopwords.txt 5qden-jqaaa-aaaam-abfpa-cai ~/.local/share/icp-cli/identity/keys/search-updater.pem
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ unlighthouse.config.ts
# Local Netlify folder
.netlify
/roadmap/roadmap.json
/roadmap/roadmap.d.ts
/roadmap/roadmap.d.ts

# ICP-CLI local/cache files (keep .icp/data/mappings/ for IC mainnet IDs)
.icp/cache/
3 changes: 3 additions & 0 deletions .icp/data/mappings/ic.ids.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"portal": "23pwq-taaaa-aaaaa-qdepa-cai"
}
5 changes: 0 additions & 5 deletions canister_ids.json

This file was deleted.

32 changes: 0 additions & 32 deletions dfx.json

This file was deleted.

10 changes: 10 additions & 0 deletions icp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
canisters:
- name: portal
recipe:
type: '@dfinity/asset-canister'
configuration:
version: 0.29.2
build:
- npm install
- npm run build
dir: build
1 change: 1 addition & 0 deletions search/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
project.todo
docs.json
.dfx
.icp/cache/
output.json
node_modules
.venv
Expand Down
1 change: 1 addition & 0 deletions search/.icp/data/mappings/ic.ids.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"search": "5qden-jqaaa-aaaam-abfpa-cai"}
5 changes: 0 additions & 5 deletions search/canister_ids.json

This file was deleted.

16 changes: 0 additions & 16 deletions search/dfx.json

This file was deleted.

7 changes: 7 additions & 0 deletions search/icp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
canisters:
- name: search
recipe:
type: '@dfinity/rust'
configuration:
candid: src/search_canister/candid.did
package: search_canister