Avaxc mainnet Contracts Deployment #64
Workflow file for this run
This file contains 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: Deploy and Update Release | |
on: | |
release: | |
types: [published] | |
jobs: | |
lint-and-test: | |
environment: dev | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
cache: 'npm' | |
- run: npm install | |
- run: npm run lint | |
- run: npm run test | |
env: | |
MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }} | |
PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT: ${{ secrets.PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT }} | |
PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP: ${{ secrets.PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP }} | |
TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }} | |
QUICKNODE_ETH_MAINNET_API_KEY: ${{ secrets.QUICKNODE_ETH_MAINNET_API_KEY }} | |
QUICKNODE_ETH_HOLESKY_API_KEY: ${{ secrets.QUICKNODE_ETH_HOLESKY_API_KEY }} | |
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} | |
ALCHEMY_POLYGON_API_KEY: ${{ secrets.ALCHEMY_POLYGON_API_KEY }} | |
POLYGONSCAN_API_KEY: ${{ secrets.POLYGONSCAN_API_KEY }} | |
BSCSCAN_API_KEY: ${{ secrets.BSCSCAN_API_KEY }} | |
ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }} | |
OPTIMISTIC_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISTIC_ETHERSCAN_API_KEY }} | |
get-network: | |
runs-on: ubuntu-latest | |
needs: [lint-and-test] | |
outputs: | |
network: ${{steps.network-name.outputs.result}} | |
steps: | |
- name: GET NETWORK NAME | |
id: network-name | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
result-encoding: string | |
script: | | |
const tag = process.env.GITHUB_REF_NAME; | |
const regex = /v.*\-(eth|hteth|matic|tmatic|bsc|tbsc|arbeth|tarbeth|opeth|topeth|tavaxc|avaxc)$/; | |
const network = tag.match(regex); | |
return network ? network[1] : "hteth"; | |
deploy-to-test: | |
runs-on: ubuntu-latest | |
needs: [lint-and-test, get-network] | |
if: ${{ (needs.get-network.outputs.network == 'hteth' ) || (needs.get-network.outputs.network == 'tmatic' ) || (needs.get-network.outputs.network == 'tbsc' ) || (needs.get-network.outputs.network == 'tarbeth' ) || (needs.get-network.outputs.network == 'topeth' ) || (needs.get-network.outputs.network == 'tavaxc' ) }} | |
environment: testnet | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
cache: 'npm' | |
- run: npm install | |
- run: npm run deploy-test --network ${{ needs.get-network.outputs.network }} | |
env: | |
MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }} | |
PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT: ${{ secrets.PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT }} | |
PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP: ${{ secrets.PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP }} | |
TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }} | |
QUICKNODE_ETH_MAINNET_API_KEY: ${{ secrets.QUICKNODE_ETH_MAINNET_API_KEY }} | |
QUICKNODE_ETH_HOLESKY_API_KEY: ${{ secrets.QUICKNODE_ETH_HOLESKY_API_KEY }} | |
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} | |
ALCHEMY_POLYGON_API_KEY: ${{ secrets.ALCHEMY_POLYGON_API_KEY }} | |
POLYGONSCAN_API_KEY: ${{ secrets.POLYGONSCAN_API_KEY }} | |
BSCSCAN_API_KEY: ${{ secrets.BSCSCAN_API_KEY }} | |
ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }} | |
OPTIMISTIC_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISTIC_ETHERSCAN_API_KEY }} | |
- name: Update release notes | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const fs = require('fs'); | |
const path = require('path'); | |
var json; | |
var html = ""; | |
try { | |
json = JSON.parse(fs.readFileSync('./output.json').toString()); | |
for(const key in json){ | |
html += key+": "+json[key]+"<br>"; | |
} | |
} catch (err){ | |
console.log("json file not found."); | |
} | |
const response= await github.rest.repos.getReleaseByTag({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag: "${{ github.event.release.tag_name }}" | |
}); | |
github.rest.repos.updateRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: response.data.id, | |
body: html | |
}); | |
deploy-to-prod: | |
runs-on: ubuntu-latest | |
needs: [lint-and-test, get-network] | |
if: ${{ (needs.get-network.outputs.network == 'eth' ) || (needs.get-network.outputs.network == 'matic' ) || (needs.get-network.outputs.network == 'bsc' ) || (needs.get-network.outputs.network == 'arbeth' ) || (needs.get-network.outputs.network == 'opeth' ) || (needs.get-network.outputs.network == 'avaxc' ) }} | |
environment: mainnet | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
cache: 'npm' | |
- run: npm install | |
- run: npm run deploy-prod --network ${{ needs.get-network.outputs.network }} | |
env: | |
MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.MAINNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }} | |
PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT: ${{ secrets.PRIVATE_KEY_FOR_V1_WALLET_CONTRACT_DEPLOYMENT }} | |
PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP: ${{ secrets.PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT_BACKUP }} | |
TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT: ${{ secrets.TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT }} | |
QUICKNODE_ETH_MAINNET_API_KEY: ${{ secrets.QUICKNODE_ETH_MAINNET_API_KEY }} | |
QUICKNODE_ETH_HOLESKY_API_KEY: ${{ secrets.QUICKNODE_ETH_HOLESKY_API_KEY }} | |
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} | |
ALCHEMY_POLYGON_API_KEY: ${{ secrets.ALCHEMY_POLYGON_API_KEY }} | |
POLYGONSCAN_API_KEY: ${{ secrets.POLYGONSCAN_API_KEY }} | |
BSCSCAN_API_KEY: ${{ secrets.BSCSCAN_API_KEY }} | |
ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }} | |
OPTIMISTIC_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISTIC_ETHERSCAN_API_KEY }} | |
- name: Update release notes | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const fs = require('fs'); | |
const path = require('path'); | |
var json; | |
var html = ""; | |
try { | |
json = JSON.parse(fs.readFileSync('./output.json').toString()); | |
for(const key in json){ | |
html += key+": "+json[key]+"<br>"; | |
} | |
} catch (err){ | |
console.log("json file not found."); | |
} | |
const response= await github.rest.repos.getReleaseByTag({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag: "${{ github.event.release.tag_name }}" | |
}); | |
github.rest.repos.updateRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: response.data.id, | |
body: html | |
}); |