-
Notifications
You must be signed in to change notification settings - Fork 14
Feature gitHub actions deployment pipeline #218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gfournieriExec
merged 27 commits into
develop
from
feature/github-actions-deployment-pipeline
May 13, 2025
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
e00141d
fix : avalancheFuji to avalancheFujiTestnet for hardhat network
gfournieriExec 5ef06ce
fix: rename avalancheFuji to avalancheFujiTestnet and update related …
gfournieriExec 6190635
fix: include bytecode and args in deployment saving process
gfournieriExec df8c19d
fix: update verification script path and enhance error handling
gfournieriExec 7fef22f
feat: add deployment workflow and update config script for new networks
gfournieriExec adf39e5
docs: enhance deployment instructions and add GitHub Actions workflow…
gfournieriExec bad7092
add entry to changelog
gfournieriExec cb0e5a0
fix: add condition to skip config update and artifact saving for hard…
gfournieriExec 1897a09
refactor: simplify environment variable handling in deployment workflow
gfournieriExec 9889841
fix: set default network option to 'hardhat' in deployment workflow
gfournieriExec dffaef7
fix: update environment options name
gfournieriExec fa2a482
refactor(ci): combine environment variables steps in deploy workflow
gfournieriExec 6343461
feat(deploy): integrate contract verification into deployment process
gfournieriExec 7d39f18
refactor(docs): remove redundant GitHub Actions deployment and verifi…
gfournieriExec 03e35cf
fix(ci): skip tests for mainnets environment in deployment workflow
gfournieriExec 2118ea9
feat(ci): add validation for Bellecour mainnet deployments to ensure …
gfournieriExec 562aeae
fix(ci): update validation for Bellecour mainnet deployments to requi…
gfournieriExec ba5cb6e
feat(ci): add API key environment variables for Avalanche Fuji and Ar…
gfournieriExec 14cf5eb
refactor(scripts): simplify update-config.js by removing unused param…
gfournieriExec 948bafa
fix(scripts): update update-config.js to use Hardhat for network chai…
gfournieriExec 40ed84c
fix(scripts): import config in update-config.js and refactor local co…
gfournieriExec 1999911
fix(scripts): remove redundant networkName argument from update-confi…
gfournieriExec b348f0c
feat(scripts): implement update-config.ts to manage ERC1538Proxy depl…
gfournieriExec 83098d2
fix(scripts): update update-config.ts to use deployments.get for ERC1…
gfournieriExec 94e4045
fix(scripts): update deploy workflow to use update-config.ts and remo…
gfournieriExec 01ee9cf
fix(scripts): correct variable name from localconfig to localConfig i…
gfournieriExec c520fa3
fix(scripts): remove redundant deployment file check for ERC1538Proxy…
gfournieriExec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: Deploy PoCo Contracts | ||
on: | ||
workflow_dispatch: | ||
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: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Validate mainnet deployment conditions | ||
run: | | ||
#TODO remove this when we have other mainnets | ||
if [[ "${{ inputs.environment }}" == "mainnets" && !("${{ inputs.network }}" == "bellecour" && "${{ github.ref }}" == "refs/heads/main") ]]; then | ||
echo "::error::Bellecour mainnet deployments must be made from the main branch. Current branch: ${GITHUB_REF#refs/heads/}" | ||
exit 1 | ||
fi | ||
|
||
echo "Deployment validation passed!" | ||
deploy: | ||
needs: validate | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # Required for saving deployment | ||
environment: ${{ inputs.environment }} # Use the selected environment | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Nodejs | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'npm' # Cache dependencies | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Run tests | ||
run: | | ||
if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then | ||
npm run test:arbitrumSepolia | ||
elif [ "${{ inputs.network }}" == "avalancheFujiTestnet" ]; then | ||
npm run test:fuji | ||
else | ||
npm run test | ||
fi | ||
|
||
- name: Set environment variables | ||
id: set-env | ||
run: | | ||
echo "PRIVATE_KEY=${{ secrets.PRIVATE_KEY }}" >> $GITHUB_ENV | ||
if [ "${{ inputs.network }}" == "avalancheFujiTestnet" ]; then | ||
echo "FUJI_RPC_URL=${{ secrets.FUJI_RPC_URL }}" >> $GITHUB_ENV | ||
zguesmi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo "SNOWTRACE_API_KEY=${{ secrets.SNOWTRACE_API_KEY }}" >> $GITHUB_ENV | ||
fi | ||
|
||
if [ "${{ inputs.network }}" == "arbitrumSepolia" ]; then | ||
echo "ARBITRUM_SEPOLIA_RPC_URL=${{ secrets.ARBITRUM_SEPOLIA_RPC_URL }}" >> $GITHUB_ENV | ||
echo "ARBISCAN_API_KEY=${{ secrets.ARBISCAN_API_KEY }}" >> $GITHUB_ENV | ||
fi | ||
|
||
if [ "${{ inputs.network }}" == "bellecour" ]; then | ||
echo "BELLECOUR_RPC_URL=${{ secrets.BELLECOUR_RPC_URL }}" >> $GITHUB_ENV | ||
fi | ||
|
||
- name: Deploy contracts | ||
run: | | ||
echo "Deploying to: ${{ inputs.network }} with ${{ inputs.environment }} environment" | ||
npm run deploy -- --network ${{ inputs.network }} | ||
|
||
- name: Update config.json with ERC1538Proxy address | ||
if: inputs.network != 'hardhat' | ||
run: npx hardhat run scripts/tools/update-config.ts --network ${{ inputs.network }} | ||
|
||
- name: Save deployment artifacts and updated config | ||
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: 'deployments/${{ inputs.network }}/* config/config.json' | ||
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>' |
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
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import * as fs from 'fs'; | ||
import { deployments, ethers } from 'hardhat'; | ||
import * as path from 'path'; | ||
import config from '../../utils/config'; | ||
|
||
// Get the absolute path to the config file | ||
const configPath = path.resolve('config/config.json'); | ||
|
||
async function main(): Promise<void> { | ||
// Get network info from ethers | ||
const network = await ethers.provider.getNetwork(); | ||
const networkName = network.name; | ||
const chainId = network.chainId.toString(); | ||
|
||
console.log(`Working with network: ${networkName} (Chain ID: ${chainId})`); | ||
const deployment = await deployments.get('ERC1538Proxy'); | ||
const contractAddress = deployment.address; | ||
|
||
if (!contractAddress || contractAddress === 'null') { | ||
console.error(`Failed to extract a valid ERC1538Proxy address from deployment file`); | ||
process.exit(1); | ||
} | ||
|
||
console.log(`Found ERC1538Proxy address: ${contractAddress}`); | ||
const localConfig = config; | ||
|
||
// Ensure the chain structure exists | ||
if (!localConfig.chains) { | ||
localConfig.chains = {}; | ||
} | ||
|
||
if (!localConfig.chains[chainId]) { | ||
localConfig.chains[chainId] = { | ||
_comment: `Chain ${chainId} (${networkName})`, | ||
asset: 'Token', // Default value, update as needed | ||
v3: { | ||
Hub: null, | ||
AppRegistry: null, | ||
DatasetRegistry: null, | ||
WorkerpoolRegistry: null, | ||
}, | ||
v5: {}, | ||
}; | ||
} | ||
|
||
if (!localConfig.chains[chainId].v5) { | ||
localConfig.chains[chainId].v5 = {}; | ||
} | ||
|
||
const contractKey = 'ERC1538Proxy'; | ||
const previousValue = localConfig.chains[chainId].v5[contractKey] || 'null'; | ||
localConfig.chains[chainId].v5[contractKey] = contractAddress; | ||
|
||
// Write the updated config back to file | ||
fs.writeFileSync(configPath, JSON.stringify(localConfig, null, 2)); | ||
|
||
console.log(`Updated ${chainId}.v5.${contractKey}:`); | ||
console.log(`Previous: ${previousValue}`); | ||
console.log(`New: ${contractAddress}`); | ||
} | ||
|
||
// Execute the main function and handle any errors | ||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error('Error in update-config script:', error); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.