-
Notifications
You must be signed in to change notification settings - Fork 42
133 lines (133 loc) · 5.83 KB
/
deploy-to-app.yaml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# App deployments are non-production deployments to mainnet. They are public, can be used as staging, but e.g. funds are real.
name: Deploy to app
on:
push:
branches:
- "deploy-to-app"
workflow_dispatch:
inputs:
mode:
type: choice
description: "The dfx canister install mode. See `dfx canister install --help` for details."
options:
- upgrade
- reinstall
- install
- auto
canisters:
type: choice
description: Which canisters to install
options:
- all
- nns-dapp
- sns_aggregator
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy-app:
runs-on: ubuntu-latest-m
timeout-minutes: 60
env:
NNS_DAPP_APP_SUBNET_CANISTER_ID: "xnjld-hqaaa-aaaal-qb56q-cai"
SNS_AGGREGATOR_APP_SUBNET_CANISTER_ID: "otgyv-wyaaa-aaaak-qcgba-cai"
DFX_NETWORK: app
steps:
- name: Checkout nns-dapp
uses: actions/checkout@v4
# TODO: This builds, it doesn't use a release. We probably want at least the option of using releases.
- name: Get versions
id: tool_versions
run: echo "dfx=$(jq -r .dfx dfx.json)" >> "$GITHUB_OUTPUT"
- name: Get dfx version
run: echo "DFX_VERSION=$(jq -r .dfx dfx.json)" >> $GITHUB_ENV
- name: Install dfx
uses: dfinity/setup-dfx@main
with:
dfx-version: ${{ env.DFX_VERSION }}
- name: Set credentials
run: |
printf "%s" "${{ secrets.DFX_IDENTITY_PEM }}" | dfx identity import --storage-mode=plaintext ci /dev/stdin
dfx identity use ci
env:
DFX_IDENTITY_PEM: ${{ secrets.DFX_IDENTITY_PEM }}
- name: Get SNS scripts
uses: ./.github/actions/checkout_snsdemo
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up SNS scripts
run: |
: Install more
sudo apt-get update -yy && sudo apt-get install -yy moreutils
: Add scripts to the path
echo "$PWD/snsdemo/bin" >> $GITHUB_PATH
- name: Verify identity
run: |
dfx identity whoami
dfx identity get-principal
- name: Set nns-dapp canister ID
run: |
set -x
CANISTER_NAME="nns-dapp"
export DFX_NETWORK CANISTER_NAME
jq 'del(.canisters[env.CANISTER_NAME].remote.id[env.DFX_NETWORK])' dfx.json | sponge dfx.json
dfx-canister set-id --network "$DFX_NETWORK" --canister_name "$CANISTER_NAME" --canister_id "$NNS_DAPP_APP_SUBNET_CANISTER_ID"
- name: Set sns_aggregator canister ID
run: |
set -x
CANISTER_NAME="sns_aggregator"
export DFX_NETWORK CANISTER_NAME
jq 'del(.canisters[env.CANISTER_NAME].remote.id[env.DFX_NETWORK])' dfx.json | sponge dfx.json
DFX_NETWORK="$DFX_NETWORK" jq 'del(.canisters.internet_identity.remote.id[env.DFX_NETWORK])' dfx.json | sponge dfx.json
dfx-canister set-id --network "$DFX_NETWORK" --canister_name "$CANISTER_NAME" --canister_id "$SNS_AGGREGATOR_APP_SUBNET_CANISTER_ID"
- name: Build wasms and config
uses: ./.github/actions/build_nns_dapp # Builds sns_aggregator as well.
with:
token: ${{ secrets.GITHUB_TOKEN }}
network: ${{ env.DFX_NETWORK }}
- name: Log the current state of the canisters
run: |
for canister in nns-dapp sns_aggregator ; do
echo "==== $canister ===="
set -x
dfx canister id --network app "$canister"
dfx canister info --network app "$canister"
dfx canister status --network app "$canister"
set +x
done
- name: Deploy nns-dapp
if: (inputs.canisters == 'all') || (inputs.canisters == 'nns-dapp') || ( github.event_name != 'workflow_dispatch' )
run: |
set -x
CANISTER_NAME="nns-dapp"
# Note: inputs.mode is set if this workflow is run manually, using `workflow_dispatch` defined above.
# If the workflow is triggered in another way, the inputs are not defined so we need to specify a default again.
ARGUMENT="$(cat "out/nns-dapp-arg-${DFX_NETWORK}.did")"
dfx canister install --mode "${{ inputs.mode || 'upgrade' }}" --yes --network "$DFX_NETWORK" "$CANISTER_NAME" --argument "$ARGUMENT" --wasm out/nns-dapp.wasm.gz
- name: Deploy sns_aggregator
if: (inputs.canisters == 'all') || (inputs.canisters == 'sns_aggregator') || ( github.event_name != 'workflow_dispatch' )
run: |
set -x
CANISTER_NAME="sns_aggregator"
dfx canister install --mode "${{ inputs.mode || 'upgrade' }}" --yes --network "$DFX_NETWORK" "$CANISTER_NAME" --wasm out/sns_aggregator.wasm.gz
- name: Canister info
run: |
# How to add a GitHub summary: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-adding-a-job-summary
set -x
{
MODE="${{ inputs.mode || 'upgrade' }}"
printf "## %s %s\n\nCommit: %s\nRef: %s\n\n" \
"${MODE^}" "${{ inputs.canisters }}" \
"[${GITHUB_SHA}](https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA})" \
"[${GITHUB_REF_NAME}](https://github.com/${GITHUB_REPOSITORY}/tree/${GITHUB_REF_NAME})"
for canister in nns-dapp sns_aggregator ; do
printf "## %s\n\n" "$canister"
printf "URL: "
dfx-canister-url --network "$DFX_NETWORK" "$canister"
printf "Commit: "
dfx canister metadata --network "$DFX_NETWORK" "$canister" git_commit_id || printf "NONE"
echo
dfx canister info --network "$DFX_NETWORK" "$canister"
echo
done
} >> $GITHUB_STEP_SUMMARY || true