fix: add push trigger to smart contract deploy workflow #1
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: Smart Contract Deploy | |
| on: | |
| push: | |
| workflow_dispatch: # Manual trigger | |
| inputs: | |
| network: | |
| description: 'Network' | |
| required: true | |
| type: choice | |
| options: | |
| - hardhat | |
| - avalancheFujiTestnet | |
| - arbitrumSepolia | |
| - arbitrum | |
| - bellecour | |
| default: 'hardhat' | |
| concurrency: | |
| group: ${{ github.ref }}-core-smart-contract-ci | |
| cancel-in-progress: true | |
| jobs: | |
| build-and-test: | |
| uses: ./.github/workflows/core-smart-contract-ci.yml | |
| with: | |
| node-version: 20 | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| working-directory: packages/smart-contract | |
| run: npm ci | |
| - name: Deploy contract | |
| working-directory: packages/smart-contract | |
| env: | |
| # For Deployment | |
| RPC_URL: ${{ secrets.RPC_URL }} | |
| DEPLOYER_PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }} | |
| DATASET_REGISTRY_ADDRESS: ${{ vars.DATASET_REGISTRY_ADDRESS }} | |
| # For Verification | |
| EXPLORER_API_KEY: ${{ secrets.EXPLORER_API_KEY }} | |
| run: npm run deploy -- --network ${{ inputs.network }} --deployment-id ${{ inputs.network }} --verify | |
| - name: Update production environment | |
| if: ${{ github.event.inputs.target == 'smart-contract-deploy-prod' }} | |
| working-directory: environments | |
| run: | | |
| ADDRESS=$(jq -r '.contractAddress' ../packages/smart-contract/ignition/deployments/chain-134/journal.jsonl) | |
| BLOCK=$(jq -r '.blockNumber' ../packages/smart-contract/ignition/deployments/chain-134/journal.jsonl) | |
| KEY=dataprotectorContractAddress VALUE=$ADDRESS npm run update-env | |
| KEY=dataprotectorStartBlock VALUE=$BLOCK npm run update-env | |
| git add environments.json | |
| git commit -m "Deployment ${{ github.event.inputs.target }} run ${{ github.run_number }} commit ${{ github.sha }}" --author="drone-product <[email protected]>" | |
| - name: Update staging environment | |
| if: ${{ github.event.inputs.target == 'smart-contract-deploy-staging' }} | |
| working-directory: environments | |
| run: | | |
| ADDRESS=$(jq -r '.contractAddress' ../packages/smart-contract/ignition/deployments/chain-134/journal.json) | |
| BLOCK=$(jq -r '.blockNumber' ../packages/smart-contract/ignition/deployments/chain-134/journal.json) | |
| KEY=dataprotectorContractAddress VALUE=$ADDRESS npm run update-env | |
| KEY=dataprotectorStartBlock VALUE=$BLOCK npm run update-env | |
| git add environments.json | |
| git commit -m "Deployment ${{ github.event.inputs.target }} run ${{ github.run_number }} commit ${{ github.sha }}" --author="drone-product <[email protected]>" | |
| - name: Git push environment update | |
| if: ${{ github.event.inputs.target == 'smart-contract-deploy-prod' || github.event.inputs.target == 'smart-contract-deploy-staging' }} | |
| run: | | |
| git push ssh://[email protected]/iExecBlockchainComputing/dataprotector-sdk.git update-env-${{ github.run_number }} | |
| env: | |
| # Configure the SSH key to secrets GitHub | |
| SSH_KEY: ${{ secrets.SSH_KEY_TEAM_PRODUCT_GITHUB_PUSH }} | |
| shell: bash |