Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/sharing-smart-contract-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Sharing Smart Contract - Deployment

on:
workflow_dispatch: # Manual trigger
inputs:
network:
description: 'Network'
required: true
type: choice
options:
- hardhat
- avalancheFujiTestnet
- arbitrumSepolia
- bellecour
default: 'hardhat'
environment:
description: 'Environment'
required: true
type: choice
options:
- testnets
- mainnets
default: 'testnets'

jobs:

# Validate deployment network and environment.
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

# On Github, the environment `mainnets` is restricted to
# the main branch. Here we check that it's only used with
# mainnet networks.
- name: Validate mainnet deployment
run: |
if [[ "${{ inputs.environment }}" == "mainnets" && "${{ inputs.network }}" != "bellecour" ]]; then
echo "::error::mainnets environment can only be used with mainnet networks."
exit 1
fi
echo "Deploying to network '${{ inputs.network }}' with environment '${{ inputs.environment }}'."

# Build and test before deploying.
ci:
needs: validate
uses: ./.github/workflows/sharing-smart-contracts-reusable.yml
with:
node-version: 18

# Run deployment steps.
deploy:
needs: ci
runs-on: ubuntu-latest
permissions:
contents: write # Required for saving deployment
environment: ${{ inputs.environment }}
steps:
- name: Set environment variables
id: set-env
run: |
echo "PRIVATE_KEY=${{ secrets.PRIVATE_KEY }}" >> $GITHUB_ENV

if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then
echo "POCO_ADDRESS=0x14B465079537655E1662F012e99EBa3863c8B9E0" >> $GITHUB_ENV
echo "DATASET_REGISTRY_ADDRESS=0x3441A0C9FE488c51fcABa2bAAA048720f4D4F72D" >> $GITHUB_ENV
echo "ARBISCAN_API_KEY=${{ secrets.ARBISCAN_API_KEY }}" >> $GITHUB_ENV
fi

- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: 18

- 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: Deploy contracts
working-directory: packages/sharing-smart-contract
run: npm run deploy -- --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>'

# TODO
- name: Verify contracts
working-directory: packages/sharing-smart-contract
run: echo "Verify contracts" # npm run verify:ignition -- <deploymentId>
6 changes: 1 addition & 5 deletions .github/workflows/sharing-smart-contracts-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
# cache: 'npm' # Cache dependencies

- name: Install Dependencies
working-directory: packages/sharing-smart-contract
run: |
node -v
npm -v
npm ci
run: npm ci

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down
2 changes: 2 additions & 0 deletions packages/sharing-smart-contract/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ RPC_URL=

## Mnemonic for the network
MNEMONIC=

ARBISCAN_API_KEY=
1 change: 1 addition & 0 deletions packages/sharing-smart-contract/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Hardhat files
cache
artifacts
!ignition/deployments/**/artifacts

# TypeChain files
typechain
Expand Down
Loading
Loading