Skip to content

Commit

Permalink
ci: fix "Prepare Environment from Latest Deployment Context"
Browse files Browse the repository at this point in the history
If we're going to call into Node anyway, then there's no need to wrap it
in fragile shell.
  • Loading branch information
danielattilasimon committed Apr 12, 2024
1 parent aae0709 commit 4cffd12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/testnet-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,8 @@ jobs:
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}

- name: Prepare Environment from Latest Deployment Context
run: |
test -f ./deployment-context-latest.json &&
cat ./deployment-context-latest.json |
pnpm tsx contracts/utils/deployment-artifacts-to-next-env.ts > ./frontend/.env.local &&
cat ./frontend/.env.local
run: pnpm tsx utils/deployment-artifacts-to-next-env.ts ../deployment-context-latest.json ../frontend/.env.local
working-directory: contracts

- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
Expand Down
17 changes: 9 additions & 8 deletions contracts/utils/deployment-artifacts-to-app-env.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { z } from "zod";
import { argv, echo, stdin } from "zx";
import { argv, echo, fs } from "zx";

const HELP = `
converts the deployment artifacts created by ./deploy into environment
variables to be used by the Next.js app located in frontend/.
Usage:
./deployment-artifacts-to-app-env.ts < deployment-latest.json
./deployment-artifacts-to-app-env.ts <INPUT_JSON> <OUTPUT_ENV>
Options:
--help, -h Show this help message.
Expand All @@ -33,18 +33,19 @@ type DeploymentContext = z.infer<typeof ZDeploymentContext>;
const NULL_ADDRESS = `0x${"0".repeat(40)}`;

export async function main() {
if ("help" in argv || "h" in argv) {
if ("help" in argv || "h" in argv || argv._.length !== 2) {
echo`${HELP}`;
process.exit(0);
}

const deploymentContext = parseDeploymentContext(await stdin());
const deploymentContext = parseDeploymentContext(await fs.readFile(argv._[0], "utf-8"));

console.log(
objectToEnvironmentVariables(
deploymentContextToAppEnvVariables(deploymentContext),
),
const outputEnv = objectToEnvironmentVariables(
deploymentContextToAppEnvVariables(deploymentContext)
);

await fs.writeFile(argv._[1], outputEnv);
console.log(outputEnv);
}

function objectToEnvironmentVariables(object: Record<string, unknown>) {
Expand Down

0 comments on commit 4cffd12

Please sign in to comment.