33 workflow_dispatch :
44 inputs :
55 network :
6- description : ' Target Network'
6+ description : ' Network'
77 required : true
88 type : choice
99 options :
1010 - hardhat
11- - avalancheFujiTestnet
11+ - avalancheFujiTestnet
1212 - arbitrumSepolia
1313 - bellecour
1414 environment :
15- description : ' Deployment Environment'
15+ description : ' Environment'
1616 required : true
1717 type : choice
1818 options :
19- - develop
20- - production
19+ - develop
20+ - production
2121 default : ' develop'
2222
2323jobs :
2424 deploy :
2525 runs-on : ubuntu-latest
2626 permissions :
27- contents : write # Required for saving deployment
28- environment : ${{ inputs.environment }} # Use the selected environment
27+ contents : write # Required for saving deployment
28+ environment : ${{ inputs.environment }} # Use the selected environment
2929 steps :
3030 - name : Checkout
3131 uses : actions/checkout@v4
32-
32+
3333 - name : Set up Nodejs
3434 uses : actions/setup-node@v4
3535 with :
3636 node-version : 20
3737 cache : ' npm' # Cache dependencies
38-
38+
3939 - name : Install dependencies
4040 run : npm ci
41-
41+
4242 - name : Run tests
4343 if : inputs.environment != 'production'
4444 run : |
@@ -49,17 +49,33 @@ jobs:
4949 else
5050 npm run test
5151 fi
52-
52+
53+ - name : Set environment variables
54+ id : set-env
55+ run : |
56+ if [ "${{ inputs.environment }}" == "production" ]; then
57+ echo "PRIVATE_KEY=${{ secrets.PROD_PRIVATE_KEY }}" >> $GITHUB_ENV
58+ else
59+ echo "PRIVATE_KEY=${{ secrets. DEV_PRIVATE_KEY }}" >> $GITHUB_ENV
60+ fi
61+
62+ if [ "${{ inputs.network }}" == "avalancheFujiTestnet" ]; then
63+ echo "FUJI_RPC_URL=${{ secrets.FUJI_RPC_URL }}" >> $GITHUB_ENV
64+ fi
65+
66+ if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then
67+ echo "ARBITRUM_SEPOLIA_RPC_URL=${{ secrets.ARBITRUM_SEPOLIA_RPC_URL }}" >> $GITHUB_ENV
68+ fi
69+
70+ if [ "${{ inputs.network }}" == "bellecour" ]; then
71+ echo "BELLECOUR_RPC_URL=${{ secrets.BELLECOUR_RPC_URL }}" >> $GITHUB_ENV
72+ fi
73+
5374 - 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 || '' }}
5975 run : |
6076 echo "Deploying to: ${{ inputs.network }} with ${{ inputs.environment }} environment"
6177 npm run deploy -- --network ${{ inputs.network }}
62-
78+
6379 - name : Update config.json with ERC1538Proxy address
6480 if : inputs.network != 'hardhat'
6581 run : |
@@ -76,27 +92,26 @@ jobs:
7692 else
7793 echo "ERC1538Proxy deployment file not found. Skipping config update."
7894 fi
79-
95+
8096 - name : Save deployment artifacts and updated config
8197 if : inputs.network != 'hardhat'
8298 uses : stefanzweifel/git-auto-commit-action@v5
8399 with :
84- commit_message : " chore: save deployment artifacts for ${{ inputs.network }} (${{ inputs.environment }}, ${{ github.run_id }})"
100+ commit_message : ' chore: save deployment artifacts for ${{ inputs.network }} (${{ inputs.environment }}, ${{ github.run_id }})'
85101 file_pattern : ' deployments/${{ inputs.network }}/* config/config.json'
86- commit_user_name : " GitHub Actions Bot"
87- commit_user_email : " github-actions[bot]@users.noreply.github.com"
88- commit_author : " GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>"
89-
102+ commit_user_name : ' GitHub Actions Bot'
103+ commit_user_email : ' github-actions[bot]@users.noreply.github.com'
104+ commit_author : ' GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>'
105+
106+ - name : Set verification environment variables
107+ if : inputs.network != 'hardhat'
108+ run : |
109+ echo "ETHERSCAN_API_KEY=${{ secrets.ETHERSCAN_API_KEY }}" >> $GITHUB_ENV
110+ echo "ARBISCAN_API_KEY=${{ secrets.ARBISCAN_API_KEY }}" >> $GITHUB_ENV
111+ echo "SNOWTRACE_API_KEY=${{ secrets.SNOWTRACE_API_KEY }}" >> $GITHUB_ENV
112+
90113 - name : Verify contracts
91114 if : inputs.network != 'hardhat'
92- env :
93- PRIVATE_KEY : ${{ inputs.environment == 'production' ? secrets.PROD_PRIVATE_KEY : secrets.DEV_PRIVATE_KEY }}
94- FUJI_RPC_URL : ${{ inputs.network == 'avalancheFujiTestnet' && secrets.FUJI_RPC_URL || '' }}
95- ARBITRUM_SEPOLIA_RPC_URL : ${{ inputs.network == 'arbitrumSepolia' && secrets.ARBITRUM_SEPOLIA_RPC_URL || '' }}
96- BELLECOUR_RPC_URL : ${{ inputs.network == 'bellecour' && secrets.BELLECOUR_RPC_URL || '' }}
97- ETHERSCAN_API_KEY : ${{ secrets.ETHERSCAN_API_KEY }}
98- ARBISCAN_API_KEY : ${{ secrets.ARBISCAN_API_KEY }}
99- SNOWTRACE_API_KEY : ${{ secrets.SNOWTRACE_API_KEY }}
100115 run : |
101116 # Add a delay to allow block explorers to index the contracts
102117 echo "Waiting for contracts to be indexed..."
0 commit comments