|
| 1 | +name: Deploy PoCo Contracts |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + network: |
| 6 | + description: 'Target Network' |
| 7 | + required: true |
| 8 | + type: choice |
| 9 | + options: |
| 10 | + - hardhat |
| 11 | + - avalancheFujiTestnet |
| 12 | + - arbitrumSepolia |
| 13 | + - bellecour |
| 14 | + environment: |
| 15 | + description: 'Deployment Environment' |
| 16 | + required: true |
| 17 | + type: choice |
| 18 | + options: |
| 19 | + - develop |
| 20 | + - production |
| 21 | + default: 'develop' |
| 22 | + |
| 23 | +jobs: |
| 24 | + deploy: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + permissions: |
| 27 | + contents: write # Required for saving deployment |
| 28 | + environment: ${{ inputs.environment }} # Use the selected environment |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Set up Nodejs |
| 34 | + uses: actions/setup-node@v4 |
| 35 | + with: |
| 36 | + node-version: 20 |
| 37 | + cache: 'npm' # Cache dependencies |
| 38 | + |
| 39 | + - name: Install dependencies |
| 40 | + run: npm ci |
| 41 | + |
| 42 | + - name: Run tests |
| 43 | + if: inputs.environment != 'production' |
| 44 | + run: | |
| 45 | + if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then |
| 46 | + npm run test:arbitrumSepolia |
| 47 | + elif [ "${{ inputs.network }}" == "avalancheFujiTestnet" ]; then |
| 48 | + npm run test:fuji |
| 49 | + else |
| 50 | + npm run test |
| 51 | + fi |
| 52 | + |
| 53 | + - name: Deploy contracts |
| 54 | + env: |
| 55 | + PRIVATE_KEY: ${{ inputs.environment == 'production' ? secrets.PROD_PRIVATE_KEY : secrets.DEV_PRIVATE_KEY }} |
| 56 | + FUJI_RPC_URL: ${{ inputs.network == 'avalancheFujiTestnet' && secrets.FUJI_RPC_URL || '' }} |
| 57 | + ARBITRUM_SEPOLIA_RPC_URL: ${{ inputs.network == 'arbitrumSepolia' && secrets.ARBITRUM_SEPOLIA_RPC_URL || '' }} |
| 58 | + BELLECOUR_RPC_URL: ${{ inputs.network == 'bellecour' && secrets.BELLECOUR_RPC_URL || '' }} |
| 59 | + run: | |
| 60 | + echo "Deploying to: ${{ inputs.network }} with ${{ inputs.environment }} environment" |
| 61 | + npm run deploy -- --network ${{ inputs.network }} |
| 62 | + |
| 63 | + - name: Update config.json with ERC1538Proxy address |
| 64 | + run: | |
| 65 | + if [ -f "deployments/${{ inputs.network }}/ERC1538Proxy.json" ]; then |
| 66 | + PROXY_ADDRESS=$(jq -r '.address' deployments/${{ inputs.network }}/ERC1538Proxy.json) |
| 67 | + # Verify we have an address before updating |
| 68 | + if [ -n "$PROXY_ADDRESS" ] && [ "$PROXY_ADDRESS" != "null" ]; then |
| 69 | + echo "Found ERC1538Proxy address: $PROXY_ADDRESS" |
| 70 | + # Update config.json using our script |
| 71 | + node scripts/update-config.js "${{ inputs.network }}" "ERC1538Proxy" "$PROXY_ADDRESS" |
| 72 | + else |
| 73 | + echo "Failed to extract a valid ERC1538Proxy address" |
| 74 | + fi |
| 75 | + else |
| 76 | + echo "ERC1538Proxy deployment file not found. Skipping config update." |
| 77 | + fi |
| 78 | + |
| 79 | + - name: Save deployment artifacts and updated config |
| 80 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 81 | + with: |
| 82 | + commit_message: "chore: save deployment artifacts for ${{ inputs.network }} (${{ inputs.environment }}, ${{ github.run_id }})" |
| 83 | + file_pattern: 'deployments/${{ inputs.network }}/* config/config.json' |
| 84 | + commit_user_name: "GitHub Actions Bot" |
| 85 | + commit_user_email: "github-actions[bot]@users.noreply.github.com" |
| 86 | + commit_author: "GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>" |
| 87 | + |
| 88 | + - name: Verify contracts |
| 89 | + if: inputs.network != 'hardhat' |
| 90 | + env: |
| 91 | + PRIVATE_KEY: ${{ inputs.environment == 'production' ? secrets.PROD_PRIVATE_KEY : secrets.DEV_PRIVATE_KEY }} |
| 92 | + FUJI_RPC_URL: ${{ inputs.network == 'avalancheFujiTestnet' && secrets.FUJI_RPC_URL || '' }} |
| 93 | + ARBITRUM_SEPOLIA_RPC_URL: ${{ inputs.network == 'arbitrumSepolia' && secrets.ARBITRUM_SEPOLIA_RPC_URL || '' }} |
| 94 | + BELLECOUR_RPC_URL: ${{ inputs.network == 'bellecour' && secrets.BELLECOUR_RPC_URL || '' }} |
| 95 | + ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} |
| 96 | + ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }} |
| 97 | + SNOWTRACE_API_KEY: ${{ secrets.SNOWTRACE_API_KEY }} |
| 98 | + run: | |
| 99 | + # Add a delay to allow block explorers to index the contracts |
| 100 | + echo "Waiting for contracts to be indexed..." |
| 101 | + sleep 60 |
| 102 | + npx hardhat run ./scripts/verify.ts --network ${{ inputs.network }} |
0 commit comments