-
Notifications
You must be signed in to change notification settings - Fork 12
135 lines (117 loc) · 6.26 KB
/
dev-merge.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
on:
pull_request:
types:
- closed
branches:
- dev
jobs:
deploy_to_testnets_on_merge:
env:
DEFENDER_TEAM_API_KEY: ${{ secrets.DEFENDER_TEAM_API_KEY }}
DEFENDER_TEAM_API_SECRET_KEY: ${{ secrets.DEFENDER_TEAM_API_SECRET_KEY }}
DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
GOERLI_BADGES_ADDRESS: ${{ secrets.GOERLI_BADGES_ADDRESS }}
GOERLI_GNOSIS_SAFE: ${{ secrets.GOERLI_GNOSIS_SAFE }}
GOERLI_RAFT_ADDRESS: ${{ secrets.GOERLI_RAFT_ADDRESS }}
GOERLI_RPC_URL: ${{ secrets.GOERLI_RPC_URL }}
GOERLI_SPECDATAHOLDER_ADDRESS: ${{ secrets.GOERLI_SPECDATAHOLDER_ADDRESS }}
OPTIMISM_GOERLI_BADGES_ADDRESS: ${{ secrets.OPTIMISM_GOERLI_BADGES_ADDRESS }}
OPTIMISM_GOERLI_RAFT_ADDRESS: ${{ secrets.OPTIMISM_GOERLI_RAFT_ADDRESS }}
OPTIMISM_GOERLI_RPC_URL: ${{ secrets.OPTIMISM_GOERLI_RPC_URL }}
OPTIMISM_GOERLI_SPECDATAHOLDER_ADDRESS: ${{ secrets.OPTIMISM_GOERLI_SPECDATAHOLDER_ADDRESS }}
OPTIMISM_RPC_URL: ${{ secrets.OPTIMISM_RPC_URL }}
OPTIMISTIC_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISTIC_ETHERSCAN_API_KEY }}
SEPOLIA_BADGES_ADDRESS: ${{ secrets.SEPOLIA_BADGES_ADDRESS }}
SEPOLIA_RAFT_ADDRESS: ${{ secrets.SEPOLIA_RAFT_ADDRESS }}
SEPOLIA_RPC_URL: ${{ secrets.SEPOLIA_RPC_URL }}
SEPOLIA_SPECDATAHOLDER_ADDRESS: ${{ secrets.SEPOLIA_SPECDATAHOLDER_ADDRESS }}
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install submodules
run: git submodule update --init
- name: Install yarn dependencies
run: yarn
- name: Run forge install
run: forge install
- name: Deploy
run: |
set -e
prev_tag=$(git describe --tags --abbrev=0)
echo "PREVIOUS TAG = $prev_tag"
git branch prev_tag $prev_tag
git switch prev_tag
badges_code_at_prev_tag=$(cat src/Badges.sol)
raft_code_at_prev_tag=$(cat src/Raft.sol)
sdh_code_at_prev_tag=$(cat src/SpecDataHolder.sol)
git switch dev
latest_badges_code=$(cat src/Badges.sol)
latest_raft_code=$(cat src/Raft.sol)
latest_sdh_code=$(cat src/SpecDataHolder.sol)
declare -A networks=(
["goerli"]="$GOERLI_RPC_URL $ETHERSCAN_API_KEY"
["optimism-goerli"]="$OPTIMISM_GOERLI_RPC_URL $OPTIMISTIC_ETHERSCAN_API_KEY"
["sepolia"]="$SEPOLIA_RPC_URL $ETHERSCAN_API_KEY"
)
for networkName in "${!networks[@]}"; do
read rpc_url etherscan_api_key <<<"${networks[$networkName]}"
# Initialize the list of successfully deployed contracts
deployedContracts=()
if [ "$badges_code_at_prev_tag" != "$latest_badges_code" ]; then
implementationAddress=$(forge create src/Badges.sol:Badges --private-key "$DEPLOYER_PRIVATE_KEY" --verify --rpc-url "$rpc_url" --etherscan-api-key "$etherscan_api_key" | grep "Deployed to:" | cut -d " " -f 3) || {
echo "Failed to deploy the new Badges implementation on $networkName"
exit 1
}
echo "Badges contract deployed. implementationAddress: $implementationAddress"
node scripts/createProposal.js "$implementationAddress" 'badges' "$networkName" || {
echo "Failed to create a proposal for the new Badges implementation on $networkName"
exit 1
}
# Add the contract name to the deployedContracts list
deployedContracts+=("Badges")
fi
if [ "$raft_code_at_prev_tag" != "$latest_raft_code" ]; then
implementationAddress=$(forge create src/Raft.sol:Raft --private-key "$DEPLOYER_PRIVATE_KEY" --verify --rpc-url "$rpc_url" --etherscan-api-key "$etherscan_api_key" | grep "Deployed to:" | cut -d " " -f 3) || {
echo "Failed to deploy the new Raft implementation on $networkName"
exit 1
}
echo "Raft contract deployed. implementationAddress: $implementationAddress"
node scripts/createProposal.js "$implementationAddress" 'raft' "$networkName" || {
echo "Failed to create a proposal for the new Raft implementation on $networkName"
exit 1
}
# Add the contract name to the deployedContracts list
deployedContracts+=("Raft")
fi
if [ "$sdh_code_at_prev_tag" != "$latest_sdh_code" ]; then
implementationAddress=$(forge create src/SpecDataHolder.sol:SpecDataHolder --private-key "$DEPLOYER_PRIVATE_KEY" --verify --rpc-url "$rpc_url" --etherscan-api-key "$etherscan_api_key" | grep "Deployed to:" | cut -d " " -f 3) || {
echo "Failed to deploy the new SpecDataHolder implementation on $networkName"
exit 1
}
echo "SDH contract deployed. implementationAddress: $implementationAddress"
node scripts/createProposal.js "$implementationAddress" 'specDataHolder' "$networkName" || {
echo "Failed to create a proposal for the new SpecDataHolder implementation on $networkName"
exit 1
}
# Add the contract name to the deployedContracts list
deployedContracts+=("SpecDataHolder")
fi
# Check the deployment at the end of the loop
if [ ${#deployedContracts[@]} -gt 0 ]; then
echo "Successfully deployed: ${#deployedContracts[@]} contract(s) (${deployedContracts[*]}) on $networkName"
else
echo "No implementations deployed on $networkName"
fi
done