-
Notifications
You must be signed in to change notification settings - Fork 42
113 lines (96 loc) · 3.46 KB
/
auto-deploy-contracts.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
name: Auto-deploy IPC contracts to Calibrationnet when changed
on:
workflow_dispatch:
push:
branches:
- main
paths:
- contracts/**
permissions:
contents: write
env:
GIT_USERNAME: github-actions[bot]
GIT_EMAIL: ipc+github-actions[bot]@users.noreply.github.com
concurrency:
# Only allow one run at a time for this workflow
group: auto-deploy-contracts
cancel-in-progress: true
jobs:
deploy-contracts:
runs-on: ubuntu-latest
env:
RPC_URL: https://calibration.filfox.io/rpc/v1
PRIVATE_KEY: ${{ secrets.CONTRACTS_DEPLOYER_PRIVATE_KEY }}
steps:
- name: Configure git
run: |
git config --global user.name "$GIT_USERNAME"
git config --global user.email "$GIT_EMAIL"
- name: Check out the branch that triggered this run
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
submodules: recursive
fetch-depth: 0
- uses: pnpm/action-setup@v2
- name: Set up node.js
uses: actions/setup-node@v4
with:
node-version: '21'
cache: 'pnpm'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Restore cache
id: cache-restore
uses: actions/cache/restore@v4
with:
## Hardhat is intelligent enough to perform incremental compilation. But GitHub Actions caches are immutable.
## Since we can't have a rolling cache, we create a new cache for each run, but use restore-keys to load the
## most recently created cache.
## Reference: https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key: ${{ runner.os }}-contracts-artifacts-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-contracts-artifacts-
path: |
contracts/out
contracts/deployments
contracts/artifacts
- name: Deploy IPC contracts to Calibrationnet
id: deploy_contracts
env:
REGISTRY_CREATION_PRIVILEGES: 'unrestricted'
run: |
cd contracts
pnpm install
make deploy-stack NETWORK=calibrationnet
- name: Save cache
id: cache-save
uses: actions/cache/save@v4
if: always() && steps.cache-restore.outputs.cache-hit != 'true'
with:
key: ${{ runner.os }}-contracts-artifacts-${{ github.run_id }}
path: |
contracts/out
contracts/deployments
contracts/artifacts
- name: Populate output
run: |
cd contracts
jq -n --arg commit "$(git rev-parse HEAD)" \
--arg gateway_addr "$(jq -r '.address' deployments/calibrationnet/GatewayDiamond.json)" \
--arg registry_addr "$(jq -r '.address' deployments/calibrationnet/SubnetRegistryDiamond.json)" \
'{"commit":$commit, "gateway_addr":$gateway_addr, "registry_addr":$registry_addr}' > /tmp/output.json
cat /tmp/output.json
- name: Switch code repo to cd/contracts branch
uses: actions/checkout@v4
with:
ref: cd/contracts
submodules: recursive
fetch-depth: 0
- name: Commit and push deployment info
run: |
mkdir -p deployments
cp /tmp/output.json deployments/r314159.json
git add deployments/r314159.json
git commit -m "Contracts deployed @ ${{ github.sha }}"
git push origin cd/contracts