diff --git a/.github/workflows/deploy-alchemy.yml b/.github/workflows/deploy-alchemy.yml index df5757c..178e182 100644 --- a/.github/workflows/deploy-alchemy.yml +++ b/.github/workflows/deploy-alchemy.yml @@ -45,6 +45,11 @@ jobs: AAVEGOTCHI_DIAMOND=$(node -e "console.log(require('./config/$NETWORK.json').contracts.diamond)") echo "AAVEGOTCHI_DIAMOND=$AAVEGOTCHI_DIAMOND" >> $GITHUB_OUTPUT + - name: Generate Constants + run: | + NETWORK=${{ steps.extract-network.outputs.NETWORK }} + npx ts-node scripts/generate-constants.ts $NETWORK + - name: Replace environment variables run: | sed -i "s/{{AAVEGOTCHI_DIAMOND}}/${{ steps.export-vars.outputs.AAVEGOTCHI_DIAMOND }}/g" src/helper.ts diff --git a/scripts/generate-constants.ts b/scripts/generate-constants.ts new file mode 100644 index 0000000..10a4d5b --- /dev/null +++ b/scripts/generate-constants.ts @@ -0,0 +1,17 @@ +import fs from "fs"; +import path from "path"; + +const network = process.argv[2]; +const configFile = require(`../config/${network}.json`); + +const constants = `// This is an auto-generated file +export const AAVEGOTCHI_DIAMOND = "${configFile.contracts.diamond}"; +`; + +fs.writeFileSync( + path.join(__dirname, "../src/constants.ts"), + constants, + "utf8" +); + +console.log("Constants file generated successfully");