|
| 1 | +name: Sharing Smart Contract - Deployment |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: # Manual trigger |
| 5 | + inputs: |
| 6 | + network: |
| 7 | + description: 'Network' |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - hardhat |
| 12 | + - avalancheFujiTestnet |
| 13 | + - arbitrumSepolia |
| 14 | + - bellecour |
| 15 | + default: 'hardhat' |
| 16 | + environment: |
| 17 | + description: 'Environment' |
| 18 | + required: true |
| 19 | + type: choice |
| 20 | + options: |
| 21 | + - testnets |
| 22 | + - mainnets |
| 23 | + default: 'testnets' |
| 24 | + |
| 25 | +jobs: |
| 26 | + |
| 27 | + validate: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
| 33 | + - name: Validate mainnet deployment conditions |
| 34 | + # TODO update this when we have other mainnets |
| 35 | + run: | |
| 36 | + if [[ \ |
| 37 | + "${{ inputs.environment }}" == "mainnets" && \ |
| 38 | + !("${{ inputs.network }}" == "bellecour" && "${{ github.ref }}" == "refs/heads/main") \ |
| 39 | + ]]; then |
| 40 | + echo "::error::Bellecour mainnet deployments must be made from the main branch. Current branch: ${GITHUB_REF#refs/heads/}" |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | + echo "Deployment validated!" |
| 44 | +
|
| 45 | + build-and-test: |
| 46 | + needs: validate |
| 47 | + runs-on: ubuntu-latest |
| 48 | + permissions: |
| 49 | + contents: write |
| 50 | + steps: |
| 51 | + - uses: ./common |
| 52 | + with: |
| 53 | + node-version: '18' |
| 54 | + |
| 55 | + deploy: |
| 56 | + needs: build-and-test |
| 57 | + runs-on: ubuntu-latest |
| 58 | + permissions: |
| 59 | + contents: write # Required for saving deployment |
| 60 | + environment: ${{ inputs.environment }} # Use the selected environment |
| 61 | + steps: |
| 62 | + - name: Say Hello |
| 63 | + run: echo "Hello from the deploy job!" |
| 64 | + |
| 65 | + # - uses: actions/checkout@v4 |
| 66 | + # with: |
| 67 | + # fetch-depth: 0 |
| 68 | + |
| 69 | + # - uses: actions/setup-node@v4 |
| 70 | + # with: |
| 71 | + # node-version: 18 |
| 72 | + # cache: 'npm' # Cache dependencies |
| 73 | + |
| 74 | + # - name: Install dependencies |
| 75 | + # run: npm ci |
| 76 | + |
| 77 | + # - name: Set environment variables |
| 78 | + # id: set-env |
| 79 | + # run: | |
| 80 | + # echo "PRIVATE_KEY=${{ secrets.PRIVATE_KEY }}" >> $GITHUB_ENV |
| 81 | + # if [ "${{ inputs.network }}" == "avalancheFujiTestnet" ]; then |
| 82 | + # echo "FUJI_RPC_URL=${{ secrets.FUJI_RPC_URL }}" >> $GITHUB_ENV |
| 83 | + # echo "SNOWTRACE_API_KEY=${{ secrets.SNOWTRACE_API_KEY }}" >> $GITHUB_ENV |
| 84 | + # fi |
| 85 | + |
| 86 | + # if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then |
| 87 | + # echo "ARBITRUM_SEPOLIA_RPC_URL=${{ secrets.ARBITRUM_SEPOLIA_RPC_URL }}" >> $GITHUB_ENV |
| 88 | + # echo "ARBISCAN_API_KEY=${{ secrets.ARBISCAN_API_KEY }}" >> $GITHUB_ENV |
| 89 | + # fi |
| 90 | + |
| 91 | + # if [ "${{ inputs.network }}" == "bellecour" ]; then |
| 92 | + # echo "BELLECOUR_RPC_URL=${{ secrets.BELLECOUR_RPC_URL }}" >> $GITHUB_ENV |
| 93 | + # fi |
| 94 | + |
| 95 | + # - name: Deploy contracts |
| 96 | + # run: | |
| 97 | + # echo "Deploying to: ${{ inputs.network }} with ${{ inputs.environment }} environment" |
| 98 | + # npm run deploy -- --network ${{ inputs.network }} |
| 99 | + |
| 100 | + # - name: Update config.json with ERC1538Proxy address |
| 101 | + # if: inputs.network != 'hardhat' |
| 102 | + # run: npx hardhat run scripts/tools/update-config.ts --network ${{ inputs.network }} |
| 103 | + |
| 104 | + # - name: Save deployment artifacts and updated config |
| 105 | + # if: inputs.network != 'hardhat' |
| 106 | + # uses: stefanzweifel/git-auto-commit-action@v5 |
| 107 | + # with: |
| 108 | + # commit_message: 'chore: save deployment artifacts for ${{ inputs.network }} (${{ inputs.environment }}, ${{ github.run_id }})' |
| 109 | + # file_pattern: 'deployments/${{ inputs.network }}/* config/config.json' |
| 110 | + # commit_user_name: 'GitHub Actions Bot' |
| 111 | + # commit_user_email: 'github-actions[bot]@users.noreply.github.com' |
| 112 | + # commit_author: 'GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>' |
0 commit comments