Workflow to auto deploy contracts when changed #20
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto deploy IPC contracts when changed | |
on: | |
workflow_dispatch: | |
# TODO: Test only. Remove before PR merge | |
pull_request: | |
push: | |
branches: | |
- main | |
paths: | |
- contracts/** | |
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.info/rpc/v1 | |
PRIVATE_KEY: ${{ secrets.CONTRACTS_DEPLOYER_PRIVATE_KEY }} | |
steps: | |
- name: Checkout code repo | |
uses: actions/checkout@v4 | |
with: | |
# TODO(jie): After switch to workflow_dispatch only, uncomment this | |
#ref: ${{ github.ref_name }} | |
ref: ${{ github.head_ref }} | |
submodules: recursive | |
# - name: Setup node and npm | |
# uses: actions/setup-node@v4 | |
# with: | |
# node-version: 20 | |
# cache: 'npm' | |
# cache-dependency-path: contracts/package-lock.json | |
# - name: Install Foundry | |
# uses: foundry-rs/foundry-toolchain@v1 | |
# - name: Deploy IPC contracts to calibration net | |
# id: deploy_contracts | |
# run: | | |
# cd contracts | |
# npm install --save hardhat | |
# output=$(make deploy-ipc NETWORK=calibrationnet) | |
# echo "deploy_output<<EOF" >> $GITHUB_OUTPUT | |
# echo "$output" >> $GITHUB_OUTPUT | |
# echo "EOF" >> $GITHUB_OUTPUT | |
# - name: Test create output | |
# id: gen_output | |
# run: | | |
# echo "key=$(date)" >> $GITHUB_OUTPUT | |
# - name: test use output | |
# run: echo ${{ steps.gen_output.outputs.key }} | |
# - name: Test view deploy_output | |
# run: echo "${{ steps.deploy_contracts.outputs.deploy_output }}" | |
- name: Parse deploy output | |
# deploy_output="${{ steps.deploy_contracts.outputs.deploy_output }}" | |
run: | | |
deploy_output=$(cat scripts/deploy_subnet_under_calibration_net/deploy_output.txt) | |
deployed_gateway_address=$(echo "$deploy_output" | grep '"Gateway"' | awk -F'"' '{print $4}') | |
deployed_registry_address=$(echo "$deploy_output" | grep '"SubnetRegistry"' | awk -F'"' '{print $4}') | |
echo "gateway_address=$deployed_gateway_address" >> $GITHUB_ENV | |
echo "registry_address=$deployed_registry_address" >> $GITHUB_ENV | |
- name: Read deployed addresses | |
run: | | |
echo "gateway_address: $gateway_address" | |
echo "registry_address: $registry_address" | |
- name: Write deployed address to file | |
run: | | |
mkdir -p deployments | |
jq -n '{ "commit": "${{ github.sha }}", "gateway_addr": "${gateway_address}", "registry_addr": "${registry_address}" }' > deployments/r314159.json | |
cat deployments/r314159.json |