Skip to content

Commit 83e51b5

Browse files
committed
Add CI base
1 parent b3cf19d commit 83e51b5

File tree

3 files changed

+404
-4
lines changed

3 files changed

+404
-4
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Deploy per network
2+
3+
on:
4+
push:
5+
branches:
6+
- "**"
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: deploy-per-network-${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: false
15+
16+
jobs:
17+
discover-matrix:
18+
name: Discover networks matrix
19+
runs-on: ubuntu-latest
20+
outputs:
21+
matrix: ${{ steps.build-matrix.outputs.matrix }}
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 20
30+
31+
- name: Install dependencies
32+
run: |
33+
npm ci --no-audit --no-fund --ignore-scripts
34+
35+
- id: build-matrix
36+
name: Build matrix from Catapult networks
37+
shell: bash
38+
run: |
39+
set -euo pipefail
40+
41+
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" || "${GITHUB_REF_NAME}" != "master" ]]; then
42+
FILTER="--only-testnets"
43+
else
44+
FILTER=""
45+
fi
46+
47+
# List chain IDs (one per line)
48+
CHAIN_IDS=$(./node_modules/.bin/catapult list networks --simple-chain-ids ${FILTER})
49+
50+
# Build JSON array for matrix: [{"chainId": 1, "networkName": "Ethereum"}, ...]
51+
MATRIX_ITEMS=()
52+
while IFS= read -r CHAIN_ID; do
53+
[[ -z "${CHAIN_ID}" ]] && continue
54+
NETWORK_NAME=$(./node_modules/.bin/catapult utils chain-id-to-name "${CHAIN_ID}")
55+
# Escape double quotes in network name just in case
56+
NETWORK_NAME_ESCAPED=${NETWORK_NAME//\"/\\\"}
57+
MATRIX_ITEMS+=("{\"chainId\": ${CHAIN_ID}, \"networkName\": \"${NETWORK_NAME_ESCAPED}\"}")
58+
done <<< "${CHAIN_IDS}"
59+
60+
if [[ ${#MATRIX_ITEMS[@]} -eq 0 ]]; then
61+
echo "No networks discovered" >&2
62+
echo "matrix={\"include\":[]}" >> "$GITHUB_OUTPUT"
63+
exit 0
64+
fi
65+
66+
printf -v MATRIX_JSON '{"include":[%s]}' "$(IFS=,; echo "${MATRIX_ITEMS[*]}")"
67+
68+
echo "Discovered matrix: ${MATRIX_JSON}"
69+
echo "matrix=${MATRIX_JSON}" >> "$GITHUB_OUTPUT"
70+
71+
deploy:
72+
name: Deploy to ${{ matrix.networkName }} (${{ matrix.chainId }})
73+
needs: discover-matrix
74+
runs-on: ubuntu-latest
75+
strategy:
76+
fail-fast: false
77+
matrix: ${{ fromJSON(needs.discover-matrix.outputs.matrix) }}
78+
steps:
79+
- name: Placeholder
80+
env:
81+
NETWORK_NAME: ${{ matrix.networkName }}
82+
CHAIN_ID: ${{ matrix.chainId }}
83+
run: echo "TODO: implement deployment for ${NETWORK_NAME} (${CHAIN_ID})"
84+
85+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"dry-run": "catapult dry-run"
88
},
99
"dependencies": {
10-
"catapult": "link:../live-contracts-2"
10+
"@0xsequence/catapult": "^1.1.0"
1111
}
1212
}

0 commit comments

Comments
 (0)