-
Notifications
You must be signed in to change notification settings - Fork 432
77 lines (65 loc) · 2.91 KB
/
cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Continuous Deployment job to deploy the portal to the Internet Computer as an asset canister
# as well as to the Netlify internetcomputer.org
name: CD
on:
push:
branches: [master]
repository_dispatch:
types: redeploy
jobs:
deploy-ic:
name: "Deploy to IC"
runs-on: ubuntu-latest
concurrency:
group: "website update"
cancel-in-progress: true
environment:
name: "Internet Computer Mainnet"
url: ${{ fromJson(steps.get-url.outputs.url) }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: git submodule update --init
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install DFX
uses: dfinity/setup-dfx@main
with:
dfx-version: "0.22.0"
- name: Dump 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
env:
DFX_IDENTITY_DESIGN_TEAM: ${{ 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')
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.\" } } ]}"
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
env:
CONTENTFUL_ACCESS_TOKEN: ${{ secrets.CONTENTFUL_ACCESS_TOKEN }}
CONTENTFUL_HOST: ${{ secrets.CONTENTFUL_HOST }}
CONTENTFUL_SPACE_ID: ${{ secrets.CONTENTFUL_SPACE_ID }}
AIRTABLE_KEY: ${{ secrets.AIRTABLE_SA_PORTAL_SERVICE_ACCOUNT }}
YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }}
- name: Get URL
id: get-url
run: |
URL="https://$(cat "$GITHUB_WORKSPACE/canister_ids.json" | jq -r '.portal.ic').raw.ic0.app"
echo "::set-output name=url::\"$URL\""