Search code examples
pythonchainlinkbrownieevm

Brownie Github Actions workflow


I am trying to deploy smart contracts on Ethereum Sepolia testnet using python brownie eth-brownie==1.19.3. My scripts work locally, but I want to deploy from Github Actions directly for a CICD pipeline for smart contracts.

Does anyone have a workflow.yaml for brownie?


Solution

  • The workflow.yaml below works for me. To implement this add the following variables to your repo in Settings > Secrets and variables > Actions:

    RPC HTTP URL FOR BLOCKCHAIN CONNECTIVITY:

    RPC_URL=REDACTED

    EXLORER URL API KEY FOR CONTRACT VERIFICATION:

    ETHERSCAN_TOKEN=REDACTED

    HOT WALLET PRIVATE KEY DEPLOYING THE CONTRACT

    PRIVATE_KEY=REDACTED

    NODE ADDRESS WHICH SERVES THE ORACLE REQUESTS TO THE CONTRACT

    NODE_ADDRESS=REDACTED

    WALLET ADDRESS TO OWN THE CONTRACT AFTER DEPLOYMENT & FULFILLMENT

    OWNER_ADDRESS=REDACTED

    The workflow.yaml is default set to Ethereum Sepolia, if deploying to another network, be sure to configure L25 (brownie netowks add YOUR_NETWORK...) in .github/workflows/workflow.yaml

    name: Brownie Workflow
    
    on:
      push:
        branches:
          - main
    
    jobs:
      build:
        runs-on: ubuntu-latest
        
        steps:
        - name: Checkout code
          uses: actions/checkout@v2
    
        - name: Set up Python
          uses: actions/setup-python@v2
          with:
            python-version: 3.9.13
    
        - name: Install dependencies
          run: pip install eth-brownie==1.19.3
    
        - name: Add Brownie network
          run: brownie networks add Ethereum sepolia chainid=11155111 host=${{ secrets.RPC_URL }} explorer=https://api-sepolia.etherscan.io/api
    
        - name: Compile contracts
          run: brownie compile
    
        - name: Deploy contracts
          env:
            PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
            ETHERSCAN_TOKEN: ${{ secrets.ETHERSCAN_TOKEN }}
            OWNER_ADDRESS: ${{ secrets.OWNER_ADDRESS }}
            NODE_ADDRESS: ${{ secrets.NODE_ADDRESS }}
          run: brownie run scripts/deploy.py --network sepolia
    

    Reference