Support Forums

Is there a way to populate a deploy-time (not build-time) variable

The way my app is designed to build and set up, I populate a deploy.json file in the root directory which it initially loads to configure itself and be aware of its environment, so that a single build can be placed in many different setups/deployments/etc and still behave properly. Is there some way that netlify can drop or set values inside the deploy.json file at deploy-time, after the build script has fully run and the release package created.

Welcome to the forums @mijofr

Have you considered a postbuild script? e.g

"build": "<build script>",
"postbuild": "<something else>"

Alternatively you could set your build command to something like

npm run build && pre-deploy.sh

where pre-deploy.sh is the script to populate your deploy.json.

The issue is that I’m building a package (built on github, dist pulled to netlify) intended to be able to be deployed to different setups and locations here, so the config file is intended to be per-deploy-environment, and not as part of the general build process.

I haven’t fully understood your setup, but purely based on that line, I’d say that Netlify doesn’t edit or create any files. It’s your build script. The command that you would ask Netlify to run should be the one responsible for generating/editing any kind of file that you need. So, if you can generate a file like that, Netlify can do it for you, not otherwise.