|
| 1 | +name: Deploy contracts |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: # Manual trigger |
| 5 | + inputs: |
| 6 | + network: |
| 7 | + description: 'Network' |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - anvil |
| 12 | + - sepolia |
| 13 | + - ethereum |
| 14 | + - arbitrumSepolia |
| 15 | + - arbitrum |
| 16 | + default: 'anvil' |
| 17 | + environment: |
| 18 | + description: 'Environment' |
| 19 | + required: true |
| 20 | + type: choice |
| 21 | + options: |
| 22 | + - testnets |
| 23 | + - mainnets |
| 24 | + default: 'testnets' |
| 25 | + |
| 26 | +jobs: |
| 27 | + |
| 28 | + # Validate deployment network and environment. |
| 29 | + validate: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + # On Github, the environment `mainnets` is restricted to |
| 33 | + # the main branch. Here we check that it's only used with |
| 34 | + # mainnet networks. |
| 35 | + - name: Validate mainnet deployment |
| 36 | + run: | |
| 37 | + if [[ "${{ inputs.environment }}" == "mainnets" && "${{ inputs.network }}" != "arbitrum" && "${{ inputs.network }}" != "ethereum" ]]; then |
| 38 | + echo "::error::mainnets environment can only be used with mainnet networks (ethereum, arbitrum)." |
| 39 | + exit 1 |
| 40 | + fi |
| 41 | + echo "Deploying to network '${{ inputs.network }}' with environment '${{ inputs.environment }}'." |
| 42 | +
|
| 43 | + # Build and test before deploying. |
| 44 | + ci: |
| 45 | + needs: validate |
| 46 | + uses: ./.github/workflows/main.yml |
| 47 | + |
| 48 | + # Deploy and verify contract. |
| 49 | + deploy: |
| 50 | + needs: ci |
| 51 | + runs-on: ubuntu-latest |
| 52 | + permissions: |
| 53 | + contents: write # Required to commit deployment files. |
| 54 | + environment: ${{ inputs.environment }} |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v4 |
| 57 | + with: |
| 58 | + submodules: recursive |
| 59 | + |
| 60 | + - name: Install Foundry |
| 61 | + uses: foundry-rs/foundry-toolchain@v1 |
| 62 | + with: |
| 63 | + version: stable |
| 64 | + cache: true |
| 65 | + |
| 66 | + - name: Deploy contracts on Anvil (All networks) |
| 67 | + if: inputs.network == 'anvil' |
| 68 | + env: |
| 69 | + ACCOUNT: ${{ secrets.ACCOUNT }} |
| 70 | + SEPOLIA_RPC_URL: ${{ secrets.SEPOLIA_RPC_URL }} |
| 71 | + ARBITRUM_SEPOLIA_RPC_URL: ${{ secrets.ARBITRUM_SEPOLIA_RPC_URL }} |
| 72 | + ANVIL_SEPOLIA_RPC_URL: http://localhost:8545 |
| 73 | + ANVIL_ARBITRUM_SEPOLIA_RPC_URL: http://localhost:8546 |
| 74 | + run: | |
| 75 | + make fork-sepolia & make fork-arbitrum-sepolia |
| 76 | + |
| 77 | + # Wait for anvil instances to be ready |
| 78 | + sleep 5 |
| 79 | + |
| 80 | + # Deploy all contracts using the Makefile target |
| 81 | + make deploy-on-anvil |
| 82 | +
|
| 83 | + - name: Deploy contracts on Ethereum Mainnet or Sepolia |
| 84 | + if: inputs.network == 'sepolia' || inputs.network == 'ethereum' |
| 85 | + env: |
| 86 | + ACCOUNT: ${{ secrets.ACCOUNT }} |
| 87 | + CHAIN: ${{ inputs.network }} |
| 88 | + RPC_URL: ${{ inputs.network == 'sepolia' && secrets.SEPOLIA_RPC_URL || secrets.ETHEREUM_RPC_URL }} |
| 89 | + run: | |
| 90 | + CONTRACT=RLCLiquidityUnifier make deploy-contract |
| 91 | + CONTRACT=bridges/layerZero/IexecLayerZeroBridge make deploy-contract |
| 92 | +
|
| 93 | + - name: Deploy contracts on Arbitrum/Arbitrum Sepolia (L2) |
| 94 | + if: inputs.network == 'arbitrumSepolia' || inputs.network == 'arbitrum' |
| 95 | + env: |
| 96 | + ACCOUNT: ${{ secrets.ACCOUNT }} |
| 97 | + CHAIN: ${{ inputs.network == 'arbitrumSepolia' && 'arbitrum_sepolia' || 'arbitrum' }} |
| 98 | + RPC_URL: ${{ inputs.network == 'arbitrumSepolia' && secrets.ARBITRUM_SEPOLIA_RPC_URL || secrets.ARBITRUM_RPC_URL }} |
| 99 | + run: | |
| 100 | + CONTRACT=RLCCrosschainToken make deploy-contract |
| 101 | + CONTRACT=bridges/layerZero/IexecLayerZeroBridge make deploy-contract |
| 102 | +
|
| 103 | + - name: Save deployment artifacts |
| 104 | + if: inputs.network != 'anvil' |
| 105 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 106 | + with: |
| 107 | + commit_message: 'chore: save deployment artifacts for ${{ inputs.network }} (${{ inputs.environment }}, ${{ github.run_id }})' |
| 108 | + file_pattern: 'config/config.json broadcast/' |
| 109 | + commit_user_name: 'GitHub Actions Bot' |
| 110 | + commit_user_email: 'github-actions[bot]@users.noreply.github.com' |
| 111 | + commit_author: 'GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>' |
| 112 | + |
| 113 | + - name: Verify contracts |
| 114 | + if: inputs.network != 'anvil' |
| 115 | + run: | |
| 116 | + echo "TODO: Implement contract verification for ${{ inputs.network }}." |
0 commit comments