-
Notifications
You must be signed in to change notification settings - Fork 26
251 lines (229 loc) · 7.82 KB
/
deploy.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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: Deploy OS
on:
workflow_dispatch:
inputs:
network:
description: "Network to deploy to"
required: true
type: string
kernel_address:
description: "Kernel address"
required: false
type: string
deploy_os:
description: "Deploy OS"
required: false
type: boolean
contracts:
description: "Contracts to deploy"
required: false
type: string
jobs:
build_contracts:
if: contains('["crnbarr93", "SlayerAnsh", "joemonem", "DimitrijeDragasevic", "cowboy0015"]', github.actor)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Build Contracts
run: |
make version-map
make build
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: contracts
path: ./artifacts/
if-no-files-found: error
build_schemas:
if: contains('["crnbarr93", "SlayerAnsh", "joemonem", "DimitrijeDragasevic", "cowboy0015"]', github.actor)
runs-on: ubuntu-latest
outputs:
schema_url: ${{ steps.upload-schemas.outputs.artifact-url }}
steps:
- uses: actions/checkout@v4
- name: Build Schemas
run: |
set -eo pipefail
make schemas || {
echo "Schema build failed"
exit 1
}
- name: Upload Schemas to Temp
id: upload-schemas
uses: actions/upload-artifact@v4
with:
name: temp-schemas
path: ./schemas/
retention-days: 1
if-no-files-found: error
build_deploy_script:
if: contains('["crnbarr93", "SlayerAnsh", "joemonem", "DimitrijeDragasevic", "cowboy0015"]', github.actor)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Deploy Script
run: cargo build -p andromeda-deploy --release
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: deploy
path: ./target/release/andromeda-deploy
if-no-files-found: error
deploy:
runs-on: ubuntu-latest
needs: [build_contracts, build_schemas, build_deploy_script]
env:
DEPLOYMENT_CHAIN: ${{ inputs.network }}
DEPLOYMENT_KERNEL_ADDRESS: ${{ inputs.kernel_address }}
DEPLOY_OS: ${{ inputs.deploy_os }}
DEPLOY_CONTRACTS: ${{ inputs.contracts }}
SLACK_WEBHOOK_URL: "${{ secrets.DEPLOY_SLACK_WEBHOOK_URL }}"
TEST_MNEMONIC: "${{ secrets.DEPLOY_TEST_MNEMONIC }}"
RUST_LOG: info
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: 1.76.0
components: rustfmt, clippy
- name: Download Contracts
uses: actions/download-artifact@v4
with:
name: contracts
path: "./artifacts"
- name: Download Deploy Script
uses: actions/download-artifact@v4
with:
name: deploy
path: "./"
- name: Deploy
run: |
chmod +x ./andromeda-deploy
./andromeda-deploy
trigger-schema-parser:
needs: [deploy]
runs-on: ubuntu-latest
outputs:
should_continue: ${{ steps.check-kernel.outputs.should_continue }}
steps:
- name: Set Branch Based on Kernel
id: check-kernel
run: |
KERNEL_ADDRESS="${{ inputs.kernel_address }}"
IFS=',' read -ra TESTNET_KERNELS_ARR <<< "${{ vars.TESTNET_KERNELS }}"
IFS=',' read -ra TESTNET_STAGING_KERNELS_ARR <<< "${{ vars.TESTNET_STAGING_KERNELS }}"
for kernel in "${TESTNET_KERNELS_ARR[@]}"; do
if [[ "${KERNEL_ADDRESS}" == "${kernel}" ]]; then
echo "branch=develop" >> $GITHUB_OUTPUT
echo "should_continue=true" >> $GITHUB_OUTPUT
exit 0
fi
done
for kernel in "${TESTNET_STAGING_KERNELS_ARR[@]}"; do
if [[ "${KERNEL_ADDRESS}" == "${kernel}" ]]; then
echo "branch=testnet-staging" >> $GITHUB_OUTPUT
echo "should_continue=true" >> $GITHUB_OUTPUT
exit 0
fi
done
echo "Skip: Kernel not found in known configurations"
echo "should_continue=false" >> $GITHUB_OUTPUT
- name: Checkout Schema Parser
uses: actions/checkout@v4
with:
repository: andromedaprotocol/schema-parser
ref: ${{ steps.check-kernel.outputs.branch }}
token: ${{ secrets.CI_PAT }}
- name: Download Schemas
uses: actions/download-artifact@v4
with:
name: temp-schemas
path: "packages/schema-parser/schema"
- uses: pnpm/action-setup@v4
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: "18"
cache: "pnpm"
- name: Process Schema
working-directory: packages/schema-parser
run: |
set -eo pipefail
echo "Installing dependencies..."
pnpm install
echo "Processing schema..."
npm run start
echo "Flattening schema..."
npm run flatten
echo "Exporting schema..."
npm run export
- name: Commit and Push Changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
if [[ -n $(git status --porcelain) ]]; then
git add .
git commit -m "chore: Update schema for kernel: ${{ inputs.kernel_address }}"
git push
else
echo "No changes to commit"
fi
trigger-armour-workflow:
needs: [trigger-schema-parser]
if: needs.trigger-schema-parser.outputs.should_continue == 'true'
runs-on: ubuntu-latest
steps:
- name: Wait for schema updates
run: |
echo "Waiting 6 minutes for schema updates to propagate..."
sleep 360
echo "Wait complete, proceeding with Armor workflow trigger"
- name: Download version-map
uses: actions/download-artifact@v4
with:
name: contracts
path: "artifacts"
- name: Extract version map
run: |
cd artifacts
cat version_map.json
cp version_map.json ../version_map.json
- name: Trigger Armor Workflow
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CI_PAT }}
script: |
const kernelAddress = '${{ inputs.kernel_address }}';
const testnetKernelsList = '${{ vars.TESTNET_KERNELS }}'.split(',');
const testnetStagingKernelsList = '${{ vars.TESTNET_STAGING_KERNELS }}'.split(',');
// Read the version map
const fs = require('fs');
const versionMap = fs.readFileSync('version_map.json', 'utf8');
let workflowFile;
if (testnetKernelsList.includes(kernelAddress)) {
workflowFile = 'develop.yml';
} else if (testnetStagingKernelsList.includes(kernelAddress)) {
workflowFile = 'staging.yml';
} else {
core.setFailed('Error: Kernel not found in known configurations');
return;
}
try {
await github.rest.actions.createWorkflowDispatch({
owner: 'andromedaprotocol',
repo: 'andromeda-armour',
workflow_id: workflowFile,
ref: 'main',
inputs: {
version_map: versionMap,
grep: '@smoke_test'
}
});
} catch (error) {
core.setFailed(`Failed to trigger Armor workflow: ${error.message}`);
}