Stop manually debugging your code and discover how to leverage AI to automatically detect, analyze, and resolve CI/CD pipeline failures. In this course, you will learn to bridge the gap between DevOps and automation by integrating N, OpenAI, and GitHub actions to create a fully autonomous self-healing workflow. >> Hello everyone, this is Fzini, founder of the techine. Today I am going to show you how to build a self-healing CI/CD pipeline from scratch using NAN GitHub actions and AI. We will create a system that automatically detects failures and opens up all requests to apply the fix. No more manual debugging. Let's get started. Before we jump into the implementation, let's first cover some important fundamental concepts so you have a clear picture of what we are building. Think about this. It's 3:00 a.m. and your build suddenly fails. Normally, this means you would have to wake up and spend hours digging through messy, complicated logs just to find the error. The reality is a lot of these failures are just simple typos or obvious bugs. Yet every minute your pipeline is down, it's costing the business time and money. This manual debugging process is exactly what we want to eliminate. That's where a self-healing CI/CD pipeline comes in. Instead of manual searching, AI catches the error the second it happens and performs an instant root cause analysis. But it doesn't stop there. The system actually generates a patch and opens a pull request for you. This keeps you, the developer, in total control while the AI handles all the heavy lifting. To build this, we are using a powerful tech stack. First we have git and github to manage our code and host our repositories. Then we have nitn which acts as the brain of the entire operation connecting all our tools. And finally we will be using cicd pipelines to automate the whole build test and deployment process. So how does it all actually work? Here is the flow. First a GitHub action fails during a build. That failure triggers a web hook which sends a signal directly to our niten workflow. Open AI now steps in to analyze the logs and identify exactly what went wrong. Once the fix is ready, the GitHub API creates a new branch and pushes the corrected code. Finally, you get a notification to review and merge the PR. It's that simple. All right, enough with the theory. It's time to get our hands dirty and start the practical work. To build this self-healing pipeline, we first need to set our environment with Git and GitHub. First, let's head over to Google and search for G download. Click on the very first official website. And from here, simply download the version that matches your operating system. Once the download is finished, open the setup file. Now the installation is pretty straightforward. Just keep clicking next through the default settings until it starts installing. While that's installing, let's look at GitHub. This is our version control hosting platform. If you don't have an account yet, just search GitHub and sign up. It's a very simple process just like creating an account on any other website. Now that git is installed, we need to connect our local machine to our GitHub account. For that, go to your desktop, right click and select git bash here. First, we will set our username. So, type get config dash global user.name. And here you need to type your GitHub username here this one. So I am writing here fzine dash ali and press enter. Next we will configure our email. Type get config dash global user. And here you write your email address. Make sure you use the same email address you use to create our GitHub account. Press enter. To make sure everything is set up correctly, let's run get config double dash list command. And as you can see right here, our username and email are correctly configured. Press Q for quit. And now we can close Gitbash and move on to the next step. Now that our environment is ready, let's build a simple NodeJS and ExpressJS project. To start, I will right click on my desktop and create a new folder named my dash project. Of course, feel free to name it whatever you like. Next, let's open this folder. Right click and select open with code. This will launch our project in Visual Studio Code. If you are using a different code editor, that's totally fine. But I will be sticking with Visual Studio Code for this tutorial. Once inside, let's create a new file and name it index.js. This will be the main entry point for our application. Now let's head over to the terminal and open a new terminal window. Here we are going to run npm initate minus y. The minus y flag basically says yes to all the default settings. Wait, if you get an error here, it probably means you don't have NodeJS installed. In that case, just head over to the Google, search for NodeJS download, go to the official website and install the latest version according to your operating system. Once that's done, you are good to go. As you can see, we have a package.json file. This is the most important file in your project. It contains all your project details and tracks every package we install. If this file gets messed up, the whole project could break. Now let's install our web framework. In the terminal, run npmi, which means install express. This will install ExpressJS in our project which is a powerful and popular backend framework for NodeJS. Look at our sidebar. Now we have a package-log.json file which tracks the exact version of our dependencies and there is this massive folder called node modules. This is where all the libraries and packages we use in our project actually live. It's heavy but it's the engine under the hood of our application. Now that our packages are installed, we need to define some important commands for our project. Let's open the package.json file. Inside the script section, we are going to add two very important lines which is test and build command. So I copy this and paste it here. The build command is what we will use to run our main application while the test command is what our CI/CD pipeline will use to verify if our code is actually working or not. Press Ctrl S for save and close the package.json file. Next, let's create a new file named it test.js. This is going to be our smoke test. I am going to paste this test.js code here. And let me quickly explain what's happening. First, we are setting a express server on 5,000 port. As soon as it starts, we use the HTTP method to send a request to ourselves. If we get a status code of 200, which is okay. It means the app is healthy, the test passes and the process exits with zero. If anything goes wrong or the server does not respond, it exits with one which tells our GitHub action that the build has failed. This is exactly what will trigger our selfhealing process later. Now press Ctrl S for save and open index.js file. Type a simple line here console.log log and inside the console.log we can type anything like hello from index.js and ctrl s for save. In a real world scenario this is where your entire backend logic would live. For this tutorial we are keeping it simple so we can focus on the automation part. By the way you don't worry about the copying all the code manually while watching. I have provided the link to the complete source code in the description box below. You can grab it from there for your practice. All right, let's make sure everything is working as expected before we move to the cloud. Open your terminal and run node space index.js. Perfect. As you can see, it's running successfully. Now let's test our smoke test logic by running node space test.js and press enter. And there it is. A smoke test passed. Our local environment is solid. Now let's get into the heart of this project which is building the CI/CD pipeline. Continuous integration continuous deployment pipeline. We are going to implement this using GitHub actions which allows us to automate our workflow directly within GitHub. To get started, we need to follow a specific folder structure that GitHub recognizes. In your root directory, create a new folder named GitHub. Inside that create another folder called workflows. Okay, so I am writing here workflows. And finally, inside the workflows folder, create a file named main.yml and press enter. This YL file is where we will write the instructions for our pipeline, telling GitHub exactly when to run our test and what to do if they fail. All right, let's write this line by line. Follow along with me. We start with the keyword name then a colon and we will call this CI pipeline. This is just the label for our workflow. Next, we define the trigger using on followed by a colon. This tells GitHub when to start the engine. On the next line, we indent and type push with a colon. We want this to run on every code push. On the next line, indent again and type branches followed by a colon. We need to specify which branch to watch. Add a dash here and type main. Now this pipeline is log onto our production branch. Now move back to the start and type jobs followed by a colon. This is where the actual task begin. Indent and name our first job build dash end dash test then a colon. This is our primary validation step. Next line indent again and type runs dash on then a colon and type Ubuntu dash latest. This tells GitHub to give us a fresh Linux server. Now next line type here steps followed by a colon. Then next line add a dash space and write here name with a colon and type check out code. This is just a label for the first step. Then press enter. Under that type uses colon actions / check out at the rate v4 means version 4. This is a pre-built tool that pulls our code into the runner. Then press enter. Next step again dash name colon and write here setup node.js. We need to prepare our environment. Then press enter. Type uses colon and actions/ setup dash node at the rate v4. this install NodeJS for us. Then press enter. Type with followed by a colon. We need to pass a specific setting here. Press enter. Indent here. And then type node dash version with the colon. We are using the latest and stable version which is 20. Press enter for the new step. dash name colon and write here install dependencies. Time to get our libraries. Type here run and colon and the command npm space install. This downloads everything we need. For next step again press enter dash name with colon. Type here run test. This is the moment of truth. type run with colon. And for the test command, we need to write here npm space test. If our code is broken, the pipeline will stop right here. And for the final step for this job, we need to write here dash name colon and write here build space project. For build project, press enter. write run colon and write npm space run space build and add the flag double dash if dash present so it does not error out if the script is missing. Now let's build the emergency response job. Go back to the same level as our first job and type notify dash n-on dash failure. then a colon just like before type runs dash on colon nubunt2 dash latest then press enter type needs colon space build dash end dash test this job to wait for the first one to finish then press enter type here if colon failure open and close the bracket this is the magic line. It only triggers if the build fails. Then press enter. Type steps followed with the colon. Add a dash name colon and type trigger n web hook. Then indent here type run with colon and the pipe symbol. This allows us to write a clean multi-line command. Indent here type c space dash x space post. Then in double quotes type dollar sign. For the dynamic values type double curly braces and then type secrets dot n web hook URL and then end it with a backslash. By the way, we use secrets here to keep our sensitive URLs hidden from the public. I will show you how to set these setup in GitHub settings later. Then press enter here. Type dash capital H and then in quotes type content dash type with colon space application / JSON and then another backlash. Then again type dash capital h in the double quotes type x dash web hook dash secret with the colon and then type dollar curly braces type secrets dot n web hook secret and add a backlash again here and then press enter. Again we are using a secret for the token to ensure only our authorized pipeline can talk to N8N. Now type dash with D and then a single quote and open curly braces. Type here run ID with the double quotes and outside the code write here colon. Inside the double quotes type dollar double curly braces space and write here github dotr run id. After closing the double quotes type comma and press enter. Then again open and close the double quotes. Inside the double quotes write repo with colon and then double quotes dollar double curly braces github dot repository. Write comma here and press enter. Now double quotes open and close. Inside the double quotes write here branch with colon and then double quotes dollar curly braces. Inside the curly braces write here github dotref name for the branch and after that type comma here and press enter. Type double quotes commit with colon. Again type double quotes dollar double curly braces double curly braces and inside the curly braces for getting the commit we need to write here github.sh S H A then again type comma and finally type quote actor close the quote colon quote dollar curly braces and inside the curly braces we need to write here GitHub do actor for the username close the curly braces and the single quote and we are done here to make sure everything is correct um my bad this is a steps spelling mistake and uh node version version spelling is this. Okay, control S for save. And now we are all done. Now that our code is ready and our pipeline is set, we need a place where the self-healing magic actually happens. For that, we are going to use N10 which is a powerful workflow automation tool. Let's set up our account. First, let's head over to the Google and simply search for N8N. You will see the official website right at the top, niten.io. Let's go ahead and click on that first link. Once you are on the homepage, look for the sign-in button at the top right. Now, click on start a free trial here. Enter your professional or personal email address here. Make sure it's an active one because we will need to verify it in the next step. GitHub and niten are very secure. So check your inbox for a verification code. Once you verified this, it will bring you back here to finalize the setup. Now let's fill in the basics. Enter your full name. Create a strong password and enter your account name. This will be your personal automation workplace. Now click on start free 14-day trial. Aniten will ask you a few questions to personalize your experience things like your role or what you plan to automate. Don't overthink it. You can select any options here that fits you best and click next. You can also invite team members or you can simply click on skip. Once you have cleared the questions, click on that big start automating button. This is where your journey into AIdriven DevOps truly begins. And there we go. Our account is live now to keep things clean and professional. We will click on start from scratch. This gives us a blank canvas to build our custom self-healing workflow. First, let's fix this mistake. The spelling of workflows is currently incorrect. I am going to press F2 to rename the folder and correct the spelling to the workflows. Now, press enter. And there we go. All right. Now it's time to connect the dots. We need to set up our repository and secure it with the variables we defined in our YAML file. First, let's head over to the Google. Go to your GitHub account. Click on the repositories tab and hit the new button. I will name this repository self-healing CI/CD pipeline using nitin. I will leave the description blank here because it's optional. Scroll down and then click on create repository button. Perfect. Our remote space is ready. Now we need a way for any to talk back to the GitHub to fix our code. For that we need a PA a personal access token. Think of this as a secure password that allows an application to perform actions on your behalf. Go to the your GitHub account. Click on settings button. Scroll down and then click on developer settings. Select the personal access token. We will choose tokens classic because it gives us a specific control over the scopes we need. Now click on generate new token. Select generate new token classic. I will add a note like N8N. Now the scopes are very important. We are selecting repo workflow admin and admin repo hook. We need these scopes because our AI is not just reading code. It needs permission to push fixes, update workflows and manage hooks. Scroll down and hit generate token. Copy this immediately and paste in your notepad. GitHub will not show this to you again. Now go back to the repository. Click on the settings button. Scroll down. Then click on secrets and variables and select actions. We need to add three secrets we used in our YAML file. Click on new repository secret. The first name is gh token which means GitHub token. Paste the personal access token we just copied into the field and click on add secret button. This allows our pipeline to authenticate with GitHub. Next, create another secret. Name this secret NAT web hook secret. You can type any strong string here. I will use my secret 1 2 3 and then exclamation mark. This acts as a digital handshake to an end knows the request is coming from our repository and not a random hacker. I will copy this and save this in my notepad because we will need it inside the nitn letter. Now click on add secret button. Now again click on new repository secret. The last secret is n web hook URL. For this we need to jump back to the nan. Click on the plus icon and search for the web hook node. Select this web hook node. A web hook is basically a URL that listens for data. When our pipeline fails, it will send a post request to this URL. Select the post method here and then copy this test URL. We use the test URL during development. So we can see the data coming in live. Once the project is finished, we will switch to the production. Now paste this back into our GitHub secret and save this. Double check that these names DH token and at web hook secret and at web hook URL exactly match what you wrote in your mainl file. Case sensitivity matters. Now back in VS code we will create a new file in the root directory in our project. Name this file dot get ignore and then press enter. We add node modules here because we don't want to push thousands of library files to GitHub. The pipeline will install them automatically. Press Ctrl S for save and then open your VS Code terminal. Type get init command for initialize this folder as a local Git repository. Now type get add dot to stage all our files for the first commit. Now type get commit dash m and write any message here like I'm typing here first then press enter. This saves our progress locally. Now type get remote at origin and you need to paste your GitHub repo URL here. For that go to your GitHub account. Scroll up then click on code section. Copy this URL and paste it here and then press enter. This command connect our local folder to GitHub. Now type get branch dash capital M and then main and then press enter. This command rename our default branch to main to match GitHub's standard. Now type get push- u origin and then main and then press enter. This sends our code to the cloud. Now if you refresh your page, you will see your code is live. If you check the actions tab, click on the details here. The pipeline is already running. Since our code is currently correct, the pipeline should finish with a green check mark. Now it's time to get put our system to the test. We are going to intentionally break our code and see if nit catches the failure. First let's back to the VS code and open the test.js file. I'm going to find the line const app equal to express and delete it. Without this line, the server will not initialize which will cause our smoke test to fail. Let's press Ctrl S to save this file. Now let's back to the NAN and configure our listener. I will click on the web hook and change the name to the GitHub failure web hook for better organization. Under the authentication, I will select header O and click on setup credential. This is important because we don't want just anyone triggering our workflow. I will name this N8 n web hook secret and then press enter. For the secret name, I will type x dash web hook dash secret. This must match exactly what we wrote our main.yml file. For the value, I will go to the my notepad. For value, I will go back to the notepad. Copy the secret I saved earlier and paste it right here. Scroll down and click on save button. Perfect. Our security is set. In the response mode setting, I will change it to when last node finishes and response data equal to no response body. This ensures nit acknowledge the request only after processing the logic. Now let's get back to the VS code. Open your terminal. Then type get add dot and press enter. This command is stage our broken code. Next get commit minus m and then write any message here like changes one and then press enter. We are committing this deliberate error. So the pipeline has something to react to. Before I push this code, I will go to the nitn and click on listen for test event. Now an is actively waiting for a signal from GitHub. Back to the VS code and let's run get push command and then press enter. Our broken code is now flying to GitHub. If we check to the GitHub actions, click on the code button, the pipeline will start and as expected, it's going to fail during the run test. If we click on the details button, it will immediately notify to an if we go to the nitin, click on JSON button, you can see the data has arrived in our web hook. You can see the run ID, repo, branch name, commit, actor here in the output. Now that we have the failure data, we need to find out why it failed. We need the actual error logs from GitHub. Let's close this web hook node and click on the plus icon to add a new step. Search for the HTTP request node. This node is the bridge that allows any to talk to any external API. In our case, the GitHub API. Let's add it. First, let's rename this node to fetch logs and then press enter. So, our workflow stays organized. We will keep the method as get because we are simply getting data from GitHub. Now, pay close attention to the URL. We need to point it to the specific job that https colon/appi.github.com/repos and then again slash. Now instead of typing the repo name we will make it dynamic. Go to the input data on the left. Open the body and simply drag and drop repo variable here. Now type / actions slash runs slash and again drag and drop run id here. Finally finish the URL by typing / jobs at the end. Now close this. What we just did is created a dynamic link. No matter which repository or which run fails, N10 will always fetch the correct logs for the specific instance. Now close this. GitHub's API will not gives us the data without permission. So click on authentication. Select generic credential type. From the list select beer o. Now click on setup credential. I will name this GitHub. P A means personal means personal access token. Now for the token we need our personal access token. I will go back to the notepad. Copy that long pat string we generated earlier and paste it here. Now click on save button. Close this. We are ready. Now click on execute step. It generates an error because the space of this URL. Now again click on execute step. Hitan will reach out to GitHub and bring back a detailed JSON response containing all the job details including the status and the logs location. And there it is. You can see the output right here. Now that we have the logs, we need to know exactly which files were modified in the latest commit. This helps the AI narrow down where the bug is. Let's close the fetch logs node again. Click on the plus icon. Search for the HTTP request node and add it to our canvas. I will rename this node to fetch changed files and then press enter. We are still using the get method because we are requesting information from GitHub's comparison engine. Now this URL is very very important. I'm going to type it out and explain every single part of it. Start with https colon double slash api.github.com/repose/ first we add to the repository name dynamically. So we write here double curly braces and then space dollar parentheses single quotation and select GitHub failure web hook dot first method and then dot JSON dotbody dotrepo. This ensures we are always looking at the right project. Next type slash write compare slash. Now we need to compare the state of the code before the push to the state after the push. To do that we take the current commit double curly braces again dollar sign parentheses single quotation and then select GitHub failure web hook. Again write dot first method then dot JSON dot body and then dot commit. Now I will add a tilt sign here and the number one followed by the three dots. This syntax tells GitHub show me the difference between the previous version means minus one and the current version. Finally I will add the current commit again. For that again double curly braces dollar sign parenthesis single quotation and then select GitHub failure web hook. again write dot first method and then dot JSON dot body and then dot commit. This completes the from to range. So in simple words, this URL ask GitHub what exactly changed in the specific commit. This is how the AI will know that we edited test.js and not some other files. Now close this. Click on the authentication. Select generic credential type and then select again beer o. Select GitHub P we created earlier. Now let's hit execute step. GitHub will analyze the commit and return a list of files. As you can see in the output, it clearly shows that test.js was modified. It even gives us the patch data which shows exactly what lines were added or removed. Now we know the file name is test.js but now we need to grab the actual code inside it. Let's fetch the raw content so our AI can analyze the logic. Close the fetch change files node. Click on the plus icon. Search for the HTTP request node and add it to your canvas. Now let's rename this node to fetch file content and then press enter. The reason we need this is simple. GitHub's previous response only gave us the patch or the difference. To fix the whole file AI needs the complete source code. Again we will use get method because we are downloading the file content from GitHub server. Now for the URL we are going to type a static link. We are going to use the dynamic data from previous step. Type this carefully. First write double curly braces then dollar sign and then parentheses single quotations and then select fetch changed files. Then type dot first method and then dot JSON dot files. Inside the square bracket, write zero and then dot raw underscore URL. Let me explain what this means. Fact change files tells any to look at the data from our last node. Dot first ensures we are taking the first successful response.json files points to the very first file that was changed. Dot raw URL is the magic part. It's a direct link to the plain text version of your code bypassing the GitHub UI. Now close this and then click on execute step button. If you look at the output now instead of JSON metadata, you will see your actual JavaScript code exactly as it sits in your VS code including the error was created. Now we have everything ready for the AI to take over. Now that we have the logs, the files and the code, we need to package them into a single prompt for the AI. For this, we are going to use a code node. Let's close the fetch file content node. Click on the plus icon. Search for the code node and select code in JavaScript. I will clear the default code and paste the custom JavaScript code from my notepad. Let me explain what this code is doing line by line. In the first two lines, we are capturing the payload from our original web hook and the JSON data from our fetch logs node. This gives us the basic info who, what, and where of the failure. Next, we are filtering the jobs to find exactly which one failed. We use the dotfind method to look for a status called failure. Once we find the job, we also extract the specific failed steps so that AI knows exactly where the process crashed. Then we create a step details constants. This maps out the name, status and the timing of the failure into a clear string. This is crucial context for the AI to understand the sequence of events. Now we look at the change file since a commit can have images or readme files. We define a list of code extensions like JS.ts or py. We filter the files to make sure the AI only focus on relevant source code and ignores anything that was deleted. Here we handle the file content and it can sometimes send data as a string or an object. So this logic ensures we extract the actual code correctly regardless of the format. This is the code that the AI will eventually fix. Now we build the file sections. We use a loop to go through our relevant files, identify their language like mapping JS to JavaScript and then wrap the code in markdown back takes. This ensures the AI reads the code in its proper syntax. Finally, we combine everything into a massive constant called prompt. This is a dynamic template that includes the repository, branch, commit, and the specific code files that need attention. We are also giving the AI strict instructions to return the fix in a valid JSON format so we can process it automatically in the next step. Now close this and click on execute step button. And there you go. In the output, you can see a perfectly structured report. It contains all the failure details and the source code ready to be sent to the AI. This is how you bridge the gap between the raw logs and the artificial intelligence. Now our failure report is ready. We need a brain to analyze it. Let's bring in OpenAI to find the bug and generate the solution. Let's close the code node and click on the plus icon. Search for open AI and select the action message a model for the resource. I will select text. Now a quickly tip niten gives you some free credits to start with which is great for beginners. But if you want to use your own API key for better control. I will show you how to do that. Head over to the Google search for open AI key and click on the very first official link. You will need to create an account and add at least $5 to your credit balance to activate the API. Once done, go to the API keys. Click on create new secret key. Name it whatever you want. Create secret key. Then copy this and go back to the NAN. Click on setup credential. Paste your API key here and then click on save. Now close this. Make sure the operation is message a model. For the model, we will select GPT4 mini. It is incredibly fast, cost effective and perfect for logical task like fixing code. In the messages section, set the role to the system. The reason we use the system role is to define the personality and rules for the AI. We are basically telling it how to behave throughout the conversation. I will paste this specific prompt. You are an expert DevOps engineer and NodeJS developer. Analyze the provided CI/CD failure logs and the source code. Identify the bug and provide a complete fix constraints written only a ro valid JSON object. No markdown, no code blocks, no conversational text. The branch name must be unique and specific to the fix like AI fixing express in it. Do not use main or master. The fixed code must be entire file content with the file applied. JSON schema branch name, file path, fix code, PR title and PR body. Now copy this and paste it here. Then scroll down. Now click on add message. This time we are using user role. The user role represents the actual data or question we are asking. Instead of typing, I will go to the previous output. Drag and drop our dynamic prompt. Now, if we click on execute step and look at that, we have a perfect JSON response. The AI given us a branch name, the complete fix code, and even a detailed pull request title and body. It's exactly what a human developer would do, but in seconds. Now that the AI has provided the solution, we need to clean that data and prepare GitHub for a new branch. We never push AI code directly to the main branch. Safety and manual review always comes first. Let's close this node. Click on the plus icon and search for the code node. Select code in JavaScript. Rename this node to extract AI response and then press enter. Now I am going to copy this code and paste it here. Let's break it down. We access the open AI response. If the response is empty or formatted incorrectly, we throw an error immediately to prevent the workflow from processing with bad data. This is vital. Sometimes AI reps its answer in markdown code fences. This line uses a regular expression to strip those away, leaving us with a clean JSON string. We turned that string into a real JavaScript object. We also verify that fix code field exist. If the AI failed to provide the actual fix, the process stops here. At last, we return a clean object. Notice that B 64 content line. GitHub's API requires code to be sent in B 64 format. We are converting our fix code into that specific encoding right here. So GitHub can read it. Now close this and then click on execute step. As you can see in the output, everything is now perfectly organized. We have the branch name, file path, fix code, base 64 content, PR title, PR body, repo and then commit. Now close this node and click on the plus icon. Search for the HTTP request and rename it to the create space branch and then press enter. The method must be post. We use post method because we are creating a new resource on GitHub server specifically a new git reference. For the URL type https colon double/ ai.github.com/repost/ drag and drop the repository name here. Make sure there is no space between them. Now type slash and then get then again type slash and then type refs. This is the official endpoint for creating branches. We are using the dynamic repository name we captured earlier. Now click on authentication. Select generic credential type. Select beer o and pick github pet. Since we are creating a branch modifies the repository. Your personal access token is required. Now toggle send body to on. Set the body content type to JSON. Specify body using JSON. Inside the JSON block, we will provide two key pieces of information. First, we open and close the curly braces. Inside the curly braces, open and close the double quotations. Inside the double quotations, write ref. Then after the quotations, type colon and then open and close the double quotations. Inside the double quotations, write ref / heads slash then drag and drop our branch name here. Now type comma and press enter. Again, open and close the double quotation. Inside the double quotation, type sha then type colon and then open and close the double quotations. Inside the double quotation, drag and drop your commit ID here. Ref tells GitHub the name of our new fix branch and SHA ensures the new branch starts from the exact point where the failure occurred. Now everything is fine. Click on execute step button and boom the branch is created. Now why did we create a separate branch instead of fixing the main branch directly? Security and best practices. We never want an AI to overwrite our production code without human oversight. By creating a branch, we keep the human developer in the loop to review and approve the changes before they go live. Our branch is ready. But before we can push the fix code, we need to do one very important thing. We need to get the files SHA or unique identifier. Let's start that up now. Close this node. Click on the plus icon and search for the HTTP request. Let's rename this to get file sha and then press enter. Keep the method as get. Now why are we doing this? GitHub will not let you update a file just by sending the new code. You have to provide the SHA which is like a digital fingerprint of the current file. This proves you are updating the latest version and not overwriting someone else changes by mistake. For the URL type https colon double/api.github.com/repost/ github.com/repost/ select expression here double curly braces dollar parentheses single quotation and select extract AI response then type dot item dot JSON and then dotrepo after that type slash then type contents then again type slash and then double curly braces dollar parentheses is single quotation extract AI response dot item dot JSON dot files path. Let's break down this. We are telling the GitHub API go to the specific repository. Look into the content and find this specific file path that the AI identified for fixing. By hitting this URL, GitHub will send us back the metadata of that file including its current SHA. Now close this. Under the authentication, select generic credential type. Then select bearer O and pick GitHub pet. Even though we are just reading information because this is a private repository, we must provide our token. Now click on execute step and boom, there it is. In the output, you can see field called SHA. It's a long string of numbers and letters. We will need this exact string in our next step to successfully update the code in GitHub. Now that we have the unique SHA of the file, we can finally push the AI fix back to the GitHub. Let's configure the update node. Close this node. Click on the plus icon. Search for the HTTP request node. Rename it to push fix file and press enter. For the method, we are selecting put method. We use put method because we are not creating a new file. We are replacing the content of an existing one with our corrected version. Type the following URL. https colon/api.github.com github.com/repose slash click on expression double curly braces dollar sign parentheses single quotation and select extract AI response then type dot item dot JSON dotreo after that / contents/ again double curly braces dollar parenthesis single quotation select extract AI response Then type dot item dot JSON and then dot file path. This URL targets the exact file in our repository that needs the fix. For authentication, select generic credential type. Then select beer o and pick github pet. This action requires write permission. So our token is essential. Toggle send body to on. Select body content type to JSON a specific body using fields below. We need to add four specific parameters here. First one is message for the value. So drag and drop PR title here. This serves as our commit message. Then click on add body field. Name this content. And for the value, drag and drop base 64 content. Then again click on add body. Name this SHA. Then drag and drop SHA from the previous node output. This tells GitHub, I know this is the latest version now updated. Click on add body field. Name this branch. Drag and drop the branch name from extract AI response. Now click on execute step button. The fixed code is now sitting in our new branch on GitHub. The code is fixed but we need to notify the team so they can merge it. The final step to automatically opens a pull request. So close this node. Click on the plus icon. Search for the HTTP request and rename it to open pull request. So I'm writing here open pull request and then press enter. Select the method to the post method because we are creating a new pull request. The URL is https col//appi.github.com/repos/ github.com/repose/ click on the expression then type double curly braces dollar sign parenthesis and select extract AI response then type dot item dojson dotrepo and after that / pulls this is our official link for pull request now click on authentication select generic credentials type again click on beer O and pick GitHub pet. Now toggle send body to on. Select JSON and using fields below. We will add these four parameters. First one is title. Drag and drop the PR title from extract AI response. Then click on add body field. Write name body. And for the value, drag and drop the PR body from extract AI response. Then click on add body field. Name this head. And for the value, drag and drop the branch name from extract AI response. Then again click on add body field. Name this base. And for the value right here main. This tells GitHub that we want to eventually merge our fix into the main branch. Click on the execute step button. And there we go. If we jump over to the GitHub, go to the pull request, you can see our AI generated fix waiting for review. The code changes are there and our CI/CD has successfully healed itself. If we click on merge pull request, confirm merge and boom, you successfully merge this. If we go to the code section, you can see our pipeline is successful. To make this truly professional, we should not have to check any or GitHub manually. Let's set up an automated email notification to the team knows exactly when a fix has been posted. Close the pull request node. Click the plus icon and search for Gmail. Click on this. Search for send a message. Click on sign in with Google. Check this and then click on continue. For the subject, I will type CI CD failure. Fixed and pushed by AI. Fixed and pushed by AI. Now write an email address. Select text. And for the message, I'm writing this. We are pulling the repository name from GitHub failure web hook. Branch name from extract AI response. PR title from extract AI response and JSON body repo from GitHub failure web hook. This is our email. Now close this and click on execute step. Now let's jump over to my Gmail. A realtime notification with all the details and the link to the fix. This is how you keep your team in the loop without lifting a finger. If you want to remove this attribution, you simply go to the Gmail node. Click on add options then click on append nan attribution and toggle off this. Now again if we click on execute step go back to the Gmail account and as you can see there is no nitn attribution here. Right now we are in test mode. To make this permanent part of your workflow we need to take it to production. Go back to the nitn close this. Open your GitHub failure web hook node. You will see two tabs. Test URL and production URL. Click on production URL and copy this. This URL is permanent and will always be listening for failures. Now close this and click on this publish. Click on publish. Now click on go. Got it. Your workflow is now live and running in the background. The final step to tell GitHub to use this new URL. Go to your GitHub repository. Then go to settings. Scroll down and then click on secrets and variables. Select actions. Now go to your GitHub web hook URL. Click on this pencil icon and for the value paste the updated URL here. This is your production URL. Now click on update secret. And that's it. You have built a fully autonomous AI powered self-filling CI/CD pipeline. From detecting a failure to analyzing logs, writing code, and notify the team, everything is now automated. This project shows that AI is not here to replace developers. It's here to empower them. You can now spend less time to debugging simple errors, more time building great features. If you followed along and build this, share your results in the comments.
Generated algorithmically for Search Engine
Indexing.