Hi guys.
I have Staging set as a context and a branch to match, with a netlify.toml file that declares different Contentful API credentials for both Production (master branch) and Staging, but when I push changes to the Staging branch, it automatically deploys the code and content from the Master branch.
I’m super confused because there are significant changes between the two and I’m trying to preview new changes on the staging site prior to deploying to production.
Here are the contents of my netlify.toml file…
[context.production]
command = "echo 'Deploying to PRODUCTION'"
environment = { CONTENTFUL_ACCESS_TOKEN = "[redacted prod key]", CONTENTFUL_ENVIRONMENT = "master"}
[context.staging]
command = "echo 'Deploying to STAGING'"
environment = { CONTENTFUL_ACCESS_TOKEN = "[redacted staging key]", CONTENTFUL_ENVIRONMENT = "staging" }
Also, my publish directory is set to “public” as that’s where Gatsby builds the project. I am able to deploy successfully to Production with this setting. However, when deploying to Staging it fails with the error “failed during stage ‘building site’: Deploy directory ‘public’ does not exist”. I had to set the publish variable to “public-staging” in order to get it to succeed.
Maybe I’m missing something completely, but clearly I’m misconfiguring something. Please help.