<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Francis Ihejirika - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Francis Ihejirika - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 24 May 2026 09:04:48 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/author/francisihe/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Automate Branch-Specific Netlify Configurations with a Bash Script: A Step-by-Step Guide ]]>
                </title>
                <description>
                    <![CDATA[ When you’re working on a project with multiple environments – like staging and production – for your backend APIs and frontend deployments, you’ll want to make sure you have the correct configuration and commands for each branch in your repository. T... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-automate-branch-specific-netlify-configurations-with-a-bash-script/</link>
                <guid isPermaLink="false">6760688b00f110abd3d0f655</guid>
                
                    <category>
                        <![CDATA[ Continuous Integration ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Netlify ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ automation ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Bash ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Francis Ihejirika ]]>
                </dc:creator>
                <pubDate>Mon, 16 Dec 2024 17:51:07 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1733871988108/cde4ea9b-705c-40e0-9730-09dbeebdfbae.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>When you’re working on a project with multiple environments – like staging and production – for your backend APIs and frontend deployments, you’ll want to make sure you have the correct configuration and commands for each branch in your repository.</p>
<p>This can be daunting in situations where multiple developers are actively working on a codebase, making changes to different branches, or managing multiple branch-specific configurations.</p>
<p>Like with every pull request or change pushed to a branch, you’ll need to review every line of code that’s been changed, added, or removed before deciding what gets merged or not. Configuration files in codebases are not exempt from this, making them prone to errors, as a simple change can affect your entire Continuous Integration setup.</p>
<p>When changes get made to the staging or production branch and a build is triggered, you’ll want to ensure that the correct resources attached to a branch are maintained. In some cases, you may need to define different redirect rules for each respective client, custom build commands, or other settings for each branch.</p>
<p>In this article, I’ll walk through how to manage branch-specific configurations including redirects for multiple branches automatically, using a simple bash script. I’ll also show you how to safely merge context-specific rules for your staging and production branches on Netlify.</p>
<h2 id="heading-what-well-cover">What we’ll cover:</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-project-structure-and-scenario">Project Structure and Scenario</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-what-are-redirectsrewrites">What are Redirects/Rewrites?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-netlify-processes-redirects">How Netlify Processes Redirects</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-using-the-redirects-file-syntax">Using the _redirects file syntax</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-using-the-netlifytoml-configuration-file-syntax">Using the netlify.toml configuration file syntax</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-the-problem-managing-multiple-netlifytoml-files-for-different-branches">The Problem: Managing Multiple netlify.toml Files for Different Branches</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-write-the-script-to-automatically-create-our-configuration-files">How to Write the Script to Automatically Create Our Configuration File(s)</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-sample-netlifytoml-file">Sample Netlify.toml file</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-1-create-the-script-folder-and-add-the-script-file">Step 1: Create the script folder and add the script file</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-modify-packagejson-to-include-the-script-command">Step 2: Modify package.json to include the script command</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-deploy-our-client-to-netlify">How to Deploy Our Client to Netlify</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-first-deployment-of-your-project-to-netlify">First deployment of your project to Netlify</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-subsequent-deployments-how-to-set-up-branch-deployments">Subsequent Deployments / How to Set Up Branch Deployments</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-step-1-set-up-environment-variables-in-netlify-for-each-branch-context-production-staging-and-so-on">Step 1: Set Up Environment Variables in Netlify for each branch context — production, staging, and so on</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-trigger-a-new-deploy">Step 2: Trigger a new deploy</a></p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-inspect-your-deployments">Inspect Your Deployments</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-project-structure-and-scenario">Project Structure and Scenario</h2>
<p>Consider a situation where you have two separate servers deployed for a project: one to serve requests to a staging environment (deployed to Render), and another to the production environment (deployed to Google Cloud Run).</p>
<p>You also have two separate client deployments on Netlify, each with their respective API_BASE_URLs, that are served by their respective servers as illustrated below:</p>
<p><img src="https://cdn-images-1.medium.com/max/1200/1*Zat3jiq5BCucEzDHKp8yuA.png" alt="Illustration showing branches of a project repository - development, staging and production - each with its own server and client" width="600" height="400" loading="lazy"></p>
<p>The image below is a <code>sample-project</code> repository, with <code>api</code> and <code>client</code> folders/directories within it. This is an overview of the structure in each of the branches outlined above. Each directory contains its own <code>package.json</code> file, is treated as an independent component, and can be deployed to two separate services.</p>
<p><img src="https://cdn-images-1.medium.com/max/800/1*Vkh8EyIA5qamhoJOz2ksSg.png" alt="A project structure for a sample project, including directories and files for both backend and frontend. " width="600" height="400" loading="lazy"></p>
<p>In your frontend deployment for each of the clients, all your requests made to endpoints that begin with <code>/api/v1/</code> are routed to the server. Other routes remain within the frontend to direct you to pages within the client. So you’re required to write the correct rules to guide your client on how to process these requests. These are called redirect rules or rewrites.</p>
<h2 id="heading-what-are-redirectsrewrites">What are Redirects/Rewrites?</h2>
<p>Redirects, or rewrites, are rules you can create to have certain URLs automatically go to a new location anywhere on the internet (source: <a target="_blank" href="https://wpengine.com/">WPengine</a>). These are also generally known as <strong>URL forwarding</strong> and you can use them anywhere – in entire websites, sections of a website, or an entire web application.</p>
<p>In web applications, redirects are often utilized to determine how to process requests. Web hosting platforms such as Netlify and Vercel use them as well, giving developers the option to determine how their web applications process requests.</p>
<h2 id="heading-how-netlify-processes-redirects">How Netlify Processes Redirects</h2>
<p>Netlify has two possible ways to specify redirect rules. You can do it using the <code>_redirects</code> file syntax or using the <code>netlify.toml</code> configuration file syntax. They achieve the same goal, but the <code>netlify.toml</code> syntax gives you more options and capabilities.</p>
<h3 id="heading-using-the-redirects-file-syntax">Using the <code>_redirects</code> file syntax</h3>
<p>If you opt to use the redirect syntax, you should simply create a <code>_redirects</code> file in the public folder of your client app, and specify the redirect rules within it. That’s as easy as it gets. Below is an example of a redirect rule within the file:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733944577546/2f21a9b9-6843-4900-a6fe-5573a087b3d9.png" alt="Sample Netlify _redirects file showing usage syntax and redirect rules" class="image--center mx-auto" width="745" height="143" loading="lazy"></p>
<p>The above rule can be interpreted as:</p>
<ol>
<li><p>Send all my requests that match <code>/api/v1</code> to the API URL specified, and return a 200 success status code. The asterisks (*) after <code>/api/v1/</code> as seen in <code>/api/v1/*</code> instruct it to append any other extension of the original URL to the stated API URL. For example, if you have a <code>/api/v1/users</code> route in your frontend, that request will be redirected to <code>https://your-api-base-url.com/api/v1/users</code>. The <code>:splat</code> seen in the API URL is simply a placeholder.</p>
</li>
<li><p>Serve all other default routes through the index.html folder. This is required to ensure that you don’t encounter broken pages when you navigate to other pages and attempt to visit the previous page using the “back” button.</p>
</li>
</ol>
<h3 id="heading-using-the-netlifytoml-configuration-file-syntax">Using the <code>netlify.toml</code> configuration file syntax</h3>
<p>The <code>netlify.toml</code> configuration file gives you a lot more flexibility when specifying redirect rules, including but not limited to matching the original request route, the required destination, the preferred status code response, header rules, signatures, country restrictions, roles and more.</p>
<p>This is a sample <code>netlify.toml</code> file sourced from <a target="_blank" href="https://docs.netlify.com/routing/redirects/#syntax-for-the-netlify-configuration-file">Netlify’s documentation</a>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733947216566/f64670b4-9d28-4c50-a753-1deb27dfc646.png" alt="Sample netlify.toml file showing configuration" class="image--center mx-auto" width="717" height="488" loading="lazy"></p>
<p><strong>Quick Note:</strong> using the redirects file for redirecting certain requests to our API is perfectly fine. But it can be considered a security risk adding our API URL in plain text in the <em>redirects</em> file if the API_BASE_URL is supposed to be private. This is because any file in the public folder is what it sounds like – public – and anyone can access it.</p>
<p>If the direct locations you desire to have in your app are public URLs, then feel free to utilize the <code>_redirects</code> file syntax. But if you prefer to have a private URL(s), utilizing a <code>netlify.toml</code> configuration file in combination with the environment variables is generally a better idea.</p>
<h2 id="heading-the-problem-managing-multiple-netlifytoml-files-for-different-branches">The Problem: Managing Multiple <code>netlify.toml</code> Files for Different Branches</h2>
<p>When you use the <code>netlify.toml</code> file to define your build commands and environment-specific settings, and you make changes that are pushed to your repository and open pull requests, you have to manually ignore or edit each <code>netlify.toml</code>in each branch. This eventually becomes very stressful and susceptible to errors.</p>
<p>In addition to this, we want to avoid having our API URLs hardcoded in either our <code>_redirects</code> or <code>netlify.toml</code>file within our project codebase for security reasons. We will use environment variables as provided within our Netlify UI for production and staging contexts.</p>
<p>To avoid the above problems, we will use a small script in our codebase to dynamically generate the correct <code>netlify.toml</code> files for each branch. This approach eliminates conflicts and removes the need for manual intervention when switching between branches or handling pull requests.</p>
<h2 id="heading-how-to-write-the-script-to-automatically-create-our-configuration-files">How to Write the Script to Automatically Create Our Configuration File(s)</h2>
<h3 id="heading-sample-netlifytoml-file">Sample <code>Netlify.toml</code> file</h3>
<p>Below is a screenshot of a sample <code>netlify.toml</code> file we are trying to achieve for each build. You can see that all our requests that match <code>api/v1/</code> in our codebase will be routed to our API.</p>
<p>You could have your API endpoint requests structured differently, for example <code>/api/your-endpoint</code> – just make sure to adjust the script accordingly. In this sample project, we use <code>api/v1/your-endpoint</code> as our structure.</p>
<p><img src="https://cdn-images-1.medium.com/max/800/1*oj_oJDA7lnC9we2zuQHm4w.png" alt="Netlify configuration file showing build commands and redirect rules" width="600" height="400" loading="lazy"></p>
<h3 id="heading-step-1-create-the-script-folder-and-add-the-script-file">Step 1: Create the script folder and add the script file</h3>
<p>In the <code>client</code> directory, create a <code>scripts/</code> directory and a <a target="_blank" href="http://configure-netlify.sh"><code>configure-netlify.sh</code></a> script file. You are required to do this for each branch in your repo. The content remains the same.</p>
<p>Open the <a target="_blank" href="http://configure-netlify.sh"><code>configure-netlify.sh</code></a> script file and paste the following content within it:</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/bash</span>

<span class="hljs-comment"># Ensure API_BASE_URL is set</span>
<span class="hljs-keyword">if</span> [ -z <span class="hljs-string">"<span class="hljs-variable">$API_BASE_URL</span>"</span> ]; <span class="hljs-keyword">then</span>
  <span class="hljs-built_in">echo</span> <span class="hljs-string">"Error: API_BASE_URL environment variable is not set."</span>
  <span class="hljs-built_in">exit</span> 1  <span class="hljs-comment"># Exit the script to stop the deployment</span>
<span class="hljs-keyword">fi</span>

<span class="hljs-built_in">echo</span> <span class="hljs-string">"Using API endpoint: <span class="hljs-variable">$API_BASE_URL</span>"</span>

<span class="hljs-comment"># Define the desired Netlify configuration</span>
NETLIFY_CONFIG=<span class="hljs-string">"
[build]
  command = \"npm install &amp;&amp; npm run build\"
  base = \"client\"
  publish = \"dist\"

[[redirects]]
  from = \"/api/v1/*\"
  to = \"<span class="hljs-variable">$API_BASE_URL</span>/:splat\"
  status = 200
  force = true

[[redirects]]
  from = \"/*\"
  to = \"/index.html\"
  status = 200
"</span>

<span class="hljs-comment"># Create or update the netlify.toml file</span>
<span class="hljs-keyword">if</span> [ ! -f <span class="hljs-string">"netlify.toml"</span> ]; <span class="hljs-keyword">then</span>
  <span class="hljs-built_in">echo</span> <span class="hljs-string">"Creating netlify.toml file..."</span>
<span class="hljs-keyword">else</span>
  <span class="hljs-built_in">echo</span> <span class="hljs-string">"Updating existing netlify.toml file..."</span>
<span class="hljs-keyword">fi</span>

<span class="hljs-built_in">echo</span> <span class="hljs-string">"<span class="hljs-variable">$NETLIFY_CONFIG</span>"</span> &gt; netlify.toml

<span class="hljs-comment"># Confirm successful configuration</span>
<span class="hljs-built_in">echo</span> <span class="hljs-string">"netlify.toml file has been configured successfully!"</span>
</code></pre>
<p>The script does the following:</p>
<ol>
<li><p>It checks the environment variables to ensure that the <code>API_BASE_URL</code> is set. If this isn’t set, it exits the build and causes it to fail. We did this to ensure that you don’t mistakenly create a successful deployment but with invalid URLs in production.</p>
</li>
<li><p>It then creates the content of the <code>netlify.toml</code> file as shown in the sample above. If your API endpoints use a different structure from <code>api/v1/your-endpoint</code>, you can adjust the script to fit your desired structure.</p>
</li>
<li><p>It checks if there already exists a <code>netlify.toml</code> file. If it doesn’t exist, it creates one and writes the content into it. If it exists, it updates it with the correct content during the build, using the <code>API_BASE_URL</code> set in the environment variables.</p>
</li>
</ol>
<h3 id="heading-step-2-modify-packagejson-to-include-the-script-command">Step 2: Modify <code>package.json</code> to include the script command</h3>
<p>To integrate this script with your build process, we will add a script command to the <code>package.json</code> file to call this script before running the actual build.</p>
<p>Add the <code>configure-netlify</code> command as follows: <code>"configure-netlify": "bash scripts/</code><a target="_blank" href="http://configure-netlify.sh"><code>configure-netlify.sh"</code></a> within the scripts in your <code>package.json</code> file.</p>
<p>Update your build command to run the script before running the actual build: <code>"build": "npm run configure-netlify &amp;&amp; vite build"</code>.</p>
<p><img src="https://cdn-images-1.medium.com/max/800/1*Sds0AS4Poe80pc9D9YkBvQ.png" alt="Image showing updated package.json file with custom configure-netlify command and updated build command" width="600" height="400" loading="lazy"></p>
<p>Don’t forget to save these changes and push them to your remote repository.</p>
<h2 id="heading-how-to-deploy-our-client-to-netlify">How to Deploy Our Client To Netlify</h2>
<p>When deploying our client to Netlify, we are given three options:</p>
<ol>
<li><p>importing an existing project (that is, a project that exists on a git repository service such as GitHub and GitLab),</p>
</li>
<li><p>importing from a template, or</p>
</li>
<li><p>manually deploying a static site using the Netlify drop (drag and drop) interface.</p>
</li>
</ol>
<p>For the configuration in our repository to work as expected during our build process, you’ll need to use the option that requires importing from an existing project such as GitHub. Using the drag-and-drop interface won’t work. If you must use this, then opt for the <code>_redirects</code> file syntax option to define your redirects.</p>
<h3 id="heading-first-deployment-of-your-project-to-netlify">First deployment of your project to Netlify</h3>
<p>When deploying your project for the first time, you are given the option of deploying only one branch initially. You can only add and specify other options, such as other branches, in subsequent deployments.</p>
<p>To deploy your project, take the following steps:</p>
<ol>
<li><p>Sign in to Netlify &gt; <a target="_blank" href="http://netlify.com">netlify.com</a></p>
</li>
<li><p>Click "Add new site" &gt; "Import an existing project" &gt; "Deploy with GitHub"</p>
</li>
<li><p>Click "Configure Netlify on GitHub" &gt; Search for your repository &gt; Select it</p>
</li>
<li><p>Enter a unique site name for your project</p>
</li>
<li><p>Configure deploy settings. Here you are required to select the preferred branch to deploy. For the initial deployment, we will deploy the <code>main</code> branch which we use as the production branch.</p>
<ul>
<li><p>Branch: main/master</p>
</li>
<li><p>Build command: <code>npm run build</code></p>
</li>
<li><p>Publish directory: <code>dist</code> (Select the directory where your static file lives. In this sample project, it’s exported into the <code>dist</code> directory. Some tools export into <code>build</code>)</p>
</li>
</ul>
</li>
<li><p>Enter the environment variables for your project. Don’t forget to enter your <code>API_BASE_URL</code> from your server. This is an essential requirement according to the bash script.</p>
</li>
<li><p>Click "Deploy site"</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733951997499/f329f2e6-b977-4b1f-a6ea-6b20610dc0d2.png" alt="Netlify deployment screen showing optional project build settings" class="image--center mx-auto" width="1919" height="934" loading="lazy"></p>
<p>Your project should deploy correctly, and you’ll be able to see the <code>netlify.toml</code> configuration generated by the script by inspecting the deployment details at the bottom of the successful deployment page.</p>
<p>You can download this file to your local machine to see the configuration generated. It should match the sample <code>netlify.toml</code> file above. You can also test that it works using your generated site link.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733952720930/97ccee2f-e93b-4205-94fa-a8ab32dd37c2.png" alt="Netlify screen showing deploy log and static files after successful deployment" class="image--center mx-auto" width="1919" height="934" loading="lazy"></p>
<h2 id="heading-subsequent-deployments-how-to-set-up-branch-deployments">Subsequent Deployments / How to Set Up Branch Deployments</h2>
<h3 id="heading-step-1-set-up-environment-variables-in-netlify-for-each-branch-context-production-staging-and-so-on">Step 1: Set Up Environment Variables in Netlify for each branch context  — production, staging, and so on</h3>
<p>When your project has been deployed successfully, you can set up deployments for your staging branch. To edit the configurations, you’ll need to:</p>
<ol>
<li><p>Navigate to the list of your sites</p>
</li>
<li><p>Select your successfully deployed site</p>
</li>
<li><p>Click on “site configuration” on the left menu</p>
</li>
<li><p>Select “environment variables” &gt; click the “Add a variable” button.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733953093253/26948920-70a7-47bc-8f53-4cb19a9d8543.png" alt="Netlify site configuration page of successfully deployed site, showing environment variables" class="image--center mx-auto" width="1919" height="934" loading="lazy"></p>
<p>You will be given the option of adding variables individually or importing an entire <code>.env</code> file. You can choose either option. In the image below, I’ve selected “Import from a <code>.env</code> file”.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734124727631/1bb20e6b-1232-4a79-bc18-2df2440cb641.png" alt="Environment variables screen showing options available to add a variable - using a single variable entry or multi entry from a .env file" class="image--center mx-auto" width="1919" height="367" loading="lazy"></p>
<p>Seeing that our production site, deployed from the <code>main</code> branch (with the production environmental variables), has already been deployed, you’ll need to:</p>
<ol>
<li><p>Uncheck the production branch (to prevent replacing the initially deployed main branch. Be careful not to mix up your environment variables for different branches)</p>
</li>
<li><p>Select “branch deploys”</p>
</li>
<li><p>Copy and paste the content of your .env file in the input section</p>
</li>
<li><p>Don’t forget to add the <code>API_BASE_URL</code> environment variable for your staging environment</p>
</li>
</ol>
<p>Note that in selecting branch deploys, the environment variables imported here will affect all branch deploys, apart from the production branch. You can further customize your contexts by selecting a custom branch, but that’s an entirely different approach which may require you to further customize your <code>netlify.toml</code> configuration file or the bash script.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733953419262/2f62d3d6-2549-4a35-aa0b-7a02225bd630.png" alt="Environment variables screen with available contexts for deployment" class="image--center mx-auto" width="1919" height="934" loading="lazy"></p>
<p>If you decide to import each environment variable individually, you are given a similar option as seen below. Ensure that you select the correct context for each branch.</p>
<p>DON’T USE THE SAME VALUES FOR ALL CONTEXTS. As seen in the image below, selecting “<em>different value for each deploy context</em>” will allow you to define the values for each one. In this case, we define the values for branch deploys. Your initially used production variable should already exist.</p>
<p><img src="https://cdn-images-1.medium.com/max/800/1*699HAdcahAzATFCDYlbqpw.png" alt="Environment variable insertion screen for single variable, showing value options for different contexts" width="600" height="400" loading="lazy"></p>
<p>When all the variables have been imported, you can inspect them to confirm that they have been correctly imported by selecting the dropdown on the right beside each variable and inspecting their values.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733954618431/66e90f42-4e3d-4c5b-95ec-a6ae03207498.png" alt="Environmental variables set for deployed web application" class="image--center mx-auto" width="1081" height="729" loading="lazy"></p>
<h3 id="heading-step-2-trigger-a-new-deploy">Step 2: Trigger a new deploy</h3>
<p>When all your environment variables have been imported for the different contexts – production and staging in this case – navigate to “deploys” on the left panel of your screen. Then hit the “Trigger deploy” button, clear the cache, and initiate a new deployment.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733954838853/79685cf6-54a5-4495-8777-914fcc46950f.png" alt="79685cf6-54a5-4495-8777-914fcc46950f" class="image--center mx-auto" width="1916" height="500" loading="lazy"></p>
<h2 id="heading-inspect-your-deployments">Inspect Your Deployments</h2>
<p>You can confirm that your script works as expected by selecting any of the deployments and selecting the building dropdown in the “Deploy log”. You will see the command run, as well as your output and API URL for that deployment, as defined by your context.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1733955355311/8268c1f3-c9cb-4b98-8094-59b7dd2d5b13.png" alt="Deploy log for successfully deployed web application, showing values logged by automation script during build" class="image--center mx-auto" width="1301" height="1005" loading="lazy"></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>By following the steps in this guide, and using your script and updated commands in each branch in your repo, when you push changes then Netlify will automatically generate or update the <code>netlify.toml</code>file in each branch. This ensures that the correct configurations and environment variables for each environment are used at build time.</p>
<p>Your script remains the same across all the branches. This lets you focus on other code changes while your script handles the correct configuration for you safely and easily.</p>
<p>Push changes to any branch to see this in action.</p>
<p>Feel free to connect with me on <a target="_blank" href="https://x.com/@francisihej">Twitter</a> (@francisihej) or <a target="_blank" href="https://linkedin.com/in/francis-ihejirika">LinkedIn</a>!</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
