|
1 | | -# deploy DataProtector smart contract to prod, dev or staging |
2 | 1 | kind: pipeline |
3 | 2 | type: docker |
4 | | -name: smart-contract deploy |
| 3 | +name: root checks |
5 | 4 |
|
6 | 5 | trigger: |
7 | 6 | event: |
8 | | - - promote |
9 | | - target: |
10 | | - # deploy and verify the DataProtector contract with the dev deployer |
11 | | - - smart-contract-deploy-dev |
12 | | - # deploy and verify the DataProtector contract with the dev deployer and commit the staging environment update |
13 | | - - smart-contract-deploy-staging |
14 | | - # deploy and verify the DataProtector contract with the prod deployer and commit the prod environment update |
15 | | - - smart-contract-deploy-prod |
16 | | - branch: |
17 | | - - develop |
18 | | - - main |
| 7 | + - pull_request |
19 | 8 |
|
20 | 9 | steps: |
21 | | - - name: install deps |
22 | | - image: node:18.19 |
23 | | - pull: always |
24 | | - commands: |
25 | | - - cd packages/smart-contract |
26 | | - - node -v |
27 | | - - npm -v |
28 | | - - npm ci |
29 | | - |
30 | | - - name: check format |
31 | | - image: node:18.19 |
32 | | - commands: |
33 | | - - cd packages/smart-contract |
34 | | - - npm run check-format |
35 | | - |
36 | | - - name: check lint |
37 | | - image: node:18.19 |
38 | | - commands: |
39 | | - - cd packages/smart-contract |
40 | | - - npm run lint |
41 | | - |
42 | | - - name: compile smart contracts |
43 | | - image: node:18.19 |
44 | | - commands: |
45 | | - - cd packages/smart-contract |
46 | | - - npm run compile |
47 | | - |
48 | | - - name: test smart contracts |
| 10 | + - name: cat-drone-consider |
49 | 11 | image: node:18.19 |
50 | 12 | commands: |
51 | | - - cd packages/smart-contract |
52 | | - - npm run test |
53 | | - |
54 | | - - name: smart-contract dev/staging deployment |
55 | | - image: node:18.19 |
56 | | - environment: |
57 | | - WALLET_PRIVATE_KEY: |
58 | | - from_secret: deployer-dev-privatekey |
59 | | - commands: |
60 | | - - cd packages/smart-contract |
61 | | - - npm run deploy -- --network bellecour |
62 | | - when: |
63 | | - target: |
64 | | - - smart-contract-deploy-staging |
65 | | - - smart-contract-deploy-dev |
66 | | - branch: |
67 | | - - develop |
| 13 | + - cat .drone-consider |
68 | 14 |
|
69 | | - - name: smart-contract prod deployment |
| 15 | + - name: check-sdk-abi |
70 | 16 | image: node:18.19 |
71 | | - environment: |
72 | | - WALLET_PRIVATE_KEY: |
73 | | - from_secret: deployer-prod-privatekey |
74 | 17 | commands: |
75 | | - - cd packages/smart-contract |
76 | | - - npm run deploy -- --network bellecour --verify |
77 | | - when: |
78 | | - target: |
79 | | - - smart-contract-deploy-prod |
80 | | - branch: |
81 | | - - main |
| 18 | + - cd packages/sdk |
| 19 | + - npm run refresh-abis |
| 20 | + - | |
| 21 | + if [ -n "$(git diff --name-only)" ]; then |
| 22 | + echo "ABIs not up-to-date in packages/sdk, need to run 'npm run refresh-abis'" |
| 23 | + exit 1 |
| 24 | + fi |
82 | 25 |
|
83 | | - - name: update prod env |
| 26 | + - name: check-subgraph-abi |
84 | 27 | image: node:18.19 |
85 | | - environment: |
86 | | - ENV: prod |
87 | 28 | commands: |
88 | | - - cd environments |
| 29 | + - cd packages/subgraph |
| 30 | + - npm run refresh-abis |
89 | 31 | - | |
90 | | - ADDRESS=$(jq -r '.contractAddress' ../packages/smart-contract/ignition/deployments/chain-134/journal.jsonl) |
91 | | - BLOCK=$(jq -r '.blockNumber' ../packages/smart-contract/ignition/deployments/chain-134/journal.jsonl) |
92 | | - KEY=dataprotectorContractAddress VALUE=$ADDRESS npm run update-env |
93 | | - KEY=dataprotectorStartBlock VALUE=$BLOCK npm run update-env |
94 | | - - git add environments.json |
95 | | - - git commit -m "$DRONE_DEPLOY_TO deployment $DRONE_BUILD_NUMBER $DRONE_COMMIT" --author="drone-product <[email protected]>" |
96 | | - when: |
97 | | - target: |
98 | | - - smart-contract-deploy-prod |
| 32 | + if [ -n "$(git diff --name-only)" ]; then |
| 33 | + echo "ABIs not up-to-date in packages/subgraph, need to run 'npm run refresh-abis'" |
| 34 | + exit 1 |
| 35 | + fi |
99 | 36 |
|
100 | | - - name: update staging env |
| 37 | + - name: check-dapp-abi |
101 | 38 | image: node:18.19 |
102 | | - environment: |
103 | | - ENV: staging |
104 | 39 | commands: |
105 | | - - cd environments |
| 40 | + - cd packages/protected-data-delivery-dapp/deployment |
| 41 | + - npm run refresh-abis |
106 | 42 | - | |
107 | | - ADDRESS=$(jq -r '.contractAddress' ../packages/smart-contract/ignition/deployments/chain-134/journal.json) |
108 | | - BLOCK=$(jq -r '.blockNumber' ../packages/smart-contract/ignition/deployments/chain-134/journal.json) |
109 | | - KEY=dataprotectorContractAddress VALUE=$ADDRESS npm run update-env |
110 | | - KEY=dataprotectorStartBlock VALUE=$BLOCK npm run update-env |
111 | | - - git add environments.json |
112 | | - - git commit -m "$DRONE_DEPLOY_TO deployment $DRONE_BUILD_NUMBER $DRONE_COMMIT" --author="drone-product <[email protected]>" |
113 | | - when: |
114 | | - target: |
115 | | - - smart-contract-deploy-staging |
116 | | - |
117 | | - - name: git-push |
118 | | - image: appleboy/drone-git-push |
119 | | - settings: |
120 | | - remote: ssh://[email protected]/iExecBlockchainComputing/dataprotector-sdk.git |
121 | | - branch: update-env-${DRONE_BUILD_NUMBER} |
122 | | - ssh_key: |
123 | | - from_secret: ssh-key-team-product-github-push |
124 | | - when: |
125 | | - target: |
126 | | - - smart-contract-deploy-prod |
127 | | - - smart-contract-deploy-staging |
| 43 | + if [ -n "$(git diff --name-only)" ]; then |
| 44 | + echo "ABIs not up-to-date in protected-data-delivery-dapp/abis, need to run 'npm run refresh-abis'" |
| 45 | + exit 1 |
| 46 | + fi |
128 | 47 |
|
129 | 48 | --- |
| 49 | + |
130 | 50 | # deploy sharing smart contract to prod, staging or dev |
131 | 51 | kind: pipeline |
132 | 52 | type: docker |
|
0 commit comments