From 20e468b049d18c740632cc8dd7589d8d57c372a7 Mon Sep 17 00:00:00 2001 From: Jonas Strassel Date: Thu, 17 Oct 2024 12:31:40 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Just=20use=20env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit instead of having to pass all the variables --- .github/workflows/test.yml | 6 ++++-- README.md | 21 +++++++++++++++++++++ action.yml | 29 +---------------------------- dist/action.js | 10 +--------- dist/action.mjs | 10 +--------- src/action.ts | 13 +------------ 6 files changed, 29 insertions(+), 60 deletions(-) create mode 100644 README.md diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 12b78d6..75c3ded 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,9 +21,11 @@ jobs: - name: test action uses: ./ with: - ALCHEMY_API_KEY: "bla" + ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} + env: RPC_POLYGON: "https://rpc.polygon.com" + - name: test action (assertion) run: | test "${{env.RPC_POLYGON}}" = "https://rpc.polygon.com" - test "${{env.RPC_MAINNET}}" = "https://eth-mainnet.g.alchemy.com/v2/bla" + test "${{env.RPC_MAINNET}}" = "https://eth-mainnet.g.alchemy.com/v2/${{ secrets.ALCHEMY_API_KEY }}" diff --git a/README.md b/README.md new file mode 100644 index 0000000..998a23b --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Action: `action-rpc-env` + +This action iterates over the supported chain ids and sets the corresponding env var. + +## Inputs + +### `ALCHEMY_API_KEY` + +Alchemy API key + +If given, the action substitute missing RPC_URLs with one constructed from the given key. + +### Usage + +``` + - uses: bgd-labs/action-rpc-env@main + with: + ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} + env: + RPC_POLYGON: "https://rpc.polygon.com" +``` diff --git a/action.yml b/action.yml index 87b0b00..5300a2f 100644 --- a/action.yml +++ b/action.yml @@ -3,34 +3,7 @@ description: "Iterates over the supported chain ids and sets the corresponding e inputs: ALCHEMY_API_KEY: description: "Alchemy API key" - RPC_MAINNET: - description: "RPC for mainnet" - RPC_POLYGON: - description: "RPC for polygon" - RPC_AVALANCHE: - description: "RPC for avalanche" - RPC_OPTIMISM: - description: "RPC for optimism" - RPC_ARBITRUM: - description: "RPC for arbitrum" - RPC_METIS: - description: "RPC for metis" - RPC_BASE: - description: "RPC for base" - RPC_FANTOM: - description: "RPC for fantom" - RPC_BNB: - description: "RPC for bnb" - RPC_GNOSIS: - description: "RPC for gnosis" - RPC_ZKEVM: - description: "RPC for polygon zk evm" - RPC_SCROLL: - description: "RPC for scroll" - RPC_ZKSYNC: - description: "RPC for zksync" - RPC_SEPOLIA: - description: "RPC for sepolia" + required: false runs: using: "node20" diff --git a/dist/action.js b/dist/action.js index ccb97fe..51b9ae3 100644 --- a/dist/action.js +++ b/dist/action.js @@ -23770,15 +23770,7 @@ var getRPCUrl = (chainId, alchemyKey2) => { var alchemyKey = (0, import_core.getInput)("ALCHEMY_API_KEY") !== "" ? (0, import_core.getInput)("ALCHEMY_API_KEY") : void 0; for (const chainId of supportedChainIds) { const envVarName = networkEnv[chainId]; - const input = (0, import_core.getInput)(envVarName); - const hasEnvVar = input && input !== ""; - if (hasEnvVar) { - (0, import_core.debug)(`Found '${envVarName}' env var and using it.`); - (0, import_core.exportVariable)(networkEnv[chainId], input); - } else { - (0, import_core.debug)(`No '${envVarName}; env var, using alchemy.`); - (0, import_core.exportVariable)(networkEnv[chainId], getRPCUrl(chainId, alchemyKey)); - } + (0, import_core.exportVariable)(envVarName, getRPCUrl(chainId, alchemyKey)); } /*! Bundled license information: diff --git a/dist/action.mjs b/dist/action.mjs index 3e8cd43..b858b0c 100644 --- a/dist/action.mjs +++ b/dist/action.mjs @@ -23775,15 +23775,7 @@ var getRPCUrl = (chainId, alchemyKey2) => { var alchemyKey = (0, import_core.getInput)("ALCHEMY_API_KEY") !== "" ? (0, import_core.getInput)("ALCHEMY_API_KEY") : void 0; for (const chainId of supportedChainIds) { const envVarName = networkEnv[chainId]; - const input = (0, import_core.getInput)(envVarName); - const hasEnvVar = input && input !== ""; - if (hasEnvVar) { - (0, import_core.debug)(`Found '${envVarName}' env var and using it.`); - (0, import_core.exportVariable)(networkEnv[chainId], input); - } else { - (0, import_core.debug)(`No '${envVarName}; env var, using alchemy.`); - (0, import_core.exportVariable)(networkEnv[chainId], getRPCUrl(chainId, alchemyKey)); - } + (0, import_core.exportVariable)(envVarName, getRPCUrl(chainId, alchemyKey)); } /*! Bundled license information: diff --git a/src/action.ts b/src/action.ts index 9656f4b..82ec1f5 100644 --- a/src/action.ts +++ b/src/action.ts @@ -11,16 +11,5 @@ const alchemyKey = */ for (const chainId of supportedChainIds) { const envVarName = networkEnv[chainId]; - - const input = getInput(envVarName); - - const hasEnvVar = input && input !== ""; - - if (hasEnvVar) { - debug(`Found '${envVarName}' env var and using it.`); - exportVariable(networkEnv[chainId], input); - } else { - debug(`No '${envVarName}; env var, using alchemy.`); - exportVariable(networkEnv[chainId], getRPCUrl(chainId, alchemyKey)); - } + exportVariable(envVarName, getRPCUrl(chainId, alchemyKey)); }