Sharing Smart Contract - Deploy or Upgrade #40
Workflow file for this run
This file contains hidden or 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: Sharing Smart Contract - Deployment | |
| on: | |
| workflow_dispatch: # Manual trigger | |
| inputs: | |
| network: | |
| description: 'Network' | |
| required: true | |
| type: choice | |
| options: | |
| - hardhat | |
| - avalancheFujiTestnet | |
| - arbitrumSepolia | |
| - arbitrum | |
| - bellecour | |
| default: 'hardhat' | |
| environment: | |
| description: 'Environment' | |
| required: true | |
| type: choice | |
| options: | |
| - dev | |
| - prod | |
| default: 'dev' | |
| jobs: | |
| # build-and-test: | |
| # uses: ./.github/workflows/sharing-smart-contracts-ci.yml | |
| # with: | |
| # node-version: 20 | |
| deploy: | |
| # needs: build-and-test | |
| runs-on: ubuntu-latest | |
| env: | |
| CI: true | |
| permissions: | |
| contents: write # Required to commit deployment files. | |
| environment: ${{ inputs.network }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| cache-dependency-path: 'packages/sharing-smart-contract' | |
| - name: Install dependencies | |
| working-directory: packages/sharing-smart-contract | |
| run: npm ci | |
| - name: Install Foundry | |
| uses: foundry-rs/foundry-toolchain@v1 | |
| with: | |
| version: stable | |
| cache: true | |
| - name: Validate deployment environment and prepare variables | |
| if: inputs.network != 'hardhat' | |
| run: | | |
| NETWORK="${{ inputs.network }}" | |
| ENVIRONMENT="${{ inputs.environment }}" | |
| case "$NETWORK" in | |
| arbitrum|bellecour) | |
| if [ "$ENVIRONMENT" = "dev" ]; then | |
| echo "Error: Cannot deploy to mainnet ($NETWORK) with dev environment" | |
| exit 1 | |
| fi | |
| echo "IS_MAINNET=true" >> $GITHUB_ENV | |
| ;; | |
| *) | |
| echo "IS_MAINNET=false" >> $GITHUB_ENV | |
| ;; | |
| esac | |
| - name: Deploy contracts | |
| id: deploy | |
| working-directory: packages/sharing-smart-contract | |
| env: | |
| # For Deployment | |
| RPC_URL: ${{ secrets.RPC_URL }} | |
| DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }} | |
| ADMIN_PRIVATE_KEY: ${{ secrets.ADMIN_PRIVATE_KEY }} | |
| POCO_ADDRESS: ${{ vars.POCO_ADDRESS }} | |
| DATASET_REGISTRY_ADDRESS: ${{ vars.DATASET_REGISTRY_ADDRESS }} | |
| run: | | |
| if [ "${{ inputs.network }}" = "hardhat" ]; then | |
| npm run deploy -- --network ${{ inputs.network }} | |
| else | |
| # For testnets, use network-environment; for mainnets, use network only | |
| if [ "$IS_MAINNET" = false ]; then | |
| DEPLOYMENT_ID="${{ inputs.network }}-${{ inputs.environment }}" | |
| else | |
| DEPLOYMENT_ID="${{ inputs.network }}" | |
| fi | |
| echo "deployment-id=$DEPLOYMENT_ID" >> $GITHUB_OUTPUT | |
| POCO_ADDRESS="${{ vars.POCO_ADDRESS }}" \ | |
| DATASET_REGISTRY_ADDRESS="${{ vars.DATASET_REGISTRY_ADDRESS }}" \ | |
| DEPLOYMENT_ID="$DEPLOYMENT_ID" \ | |
| npm run deploy -- --network ${{ inputs.network }} | |
| fi | |
| - name: Verify contracts | |
| if: inputs.network != 'hardhat' | |
| working-directory: packages/sharing-smart-contract | |
| env: | |
| # For Verification | |
| RPC_URL: ${{ secrets.RPC_URL }} | |
| EXPLORER_API_KEY: ${{ secrets.EXPLORER_API_KEY }} | |
| IS_VERIFICATION_API_V2: ${{ vars.IS_VERIFICATION_API_V2 }} | |
| run: | | |
| npm run verify:ignition -- ${{ steps.deploy.outputs.deployment-id }} --network ${{ inputs.network }} | |
| - name: Save deployment artifacts | |
| if: inputs.network != 'hardhat' | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: 'chore: save deployment artifacts for ${{ inputs.network }} ${{ inputs.environment }} (${{ github.run_id }})' | |
| file_pattern: 'packages/sharing-smart-contract/ignition/deployments/* packages/sharing-smart-contract/.openzeppelin/*' | |
| commit_user_name: 'GitHub Actions Bot' | |
| commit_user_email: 'github-actions[bot]@users.noreply.github.com' | |
| commit_author: 'GitHub Actions Bot <github-actions[bot]@users.noreply.github.com>' |