{"id":60189,"date":"2024-02-05T15:04:34","date_gmt":"2024-02-05T09:34:34","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=60189"},"modified":"2024-02-05T15:04:34","modified_gmt":"2024-02-05T09:34:34","slug":"github-actions-for-seamless-ci-cd","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/github-actions-for-seamless-ci-cd\/","title":{"rendered":"GitHub Actions for Seamless CI\/CD"},"content":{"rendered":"<h2><strong>Introduction<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">Github Actions is an automation platform that is provided by Github. Using Github Actions, you can Automate, customize, and execute your software development workflows in your GitHub repository. <\/span><span style=\"font-weight: 400;\">GitHub Actions is a continuous integration and continuous delivery (CI\/CD) platform that allows you to automate your build, test, and deployment pipeline. You can create workflows that build and test every pull request to your repository or deploy merged pull requests to production.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">GitHub Actions goes beyond DevOps and lets you run workflows when other events happen in your repository. For example, you can run a workflow to automatically add the appropriate labels whenever someone creates a new issue in your repository, check if a new branch name is given according to the given standards, etc.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60187 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.15.43\u202fPM-1024x235.png\" alt=\"\" width=\"625\" height=\"143\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.15.43\u202fPM-1024x235.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.15.43\u202fPM-300x69.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.15.43\u202fPM-768x176.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.15.43\u202fPM-1536x352.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.15.43\u202fPM-2048x470.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.15.43\u202fPM-624x143.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/span><\/p>\n<p><span style=\"font-weight: 400;\">You can control and automate your build\/deployment process using GitHub Actions. <\/span><span style=\"font-weight: 400;\">A GitHub Action workflow will be triggered when an event occurs, such as pushing the code, creating a branch, etc. \u00a0<\/span><\/p>\n<h2><strong>The components of GitHub Actions<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><strong>1. Workflow<\/strong> &#8211; Github actions workflow is a set of instructions in a yaml file. You can create as many workflows as you want. But all those workflows should be inside .github\/workflows directory in your code repository.<\/span><\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>2. Event<\/strong> &#8211; An event is a specific activity in a repository that triggers a workflow run. For example creating a branch or pushing your code etc. <\/span><span style=\"font-weight: 400;\">There is a huge list of events that can trigger a workflow run. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">See here &#8211; <\/span><a href=\"https:\/\/docs.github.com\/en\/actions\/using-workflows\/events-that-trigger-workflows\"><span style=\"font-weight: 400;\">https:\/\/docs.github.com\/en\/actions\/using-workflows\/events-that-trigger-workflows<\/span><\/a><\/p>\n<p><span style=\"font-weight: 400;\"><strong>3. Job<\/strong> &#8211; A job is a set of <\/span>steps<span style=\"font-weight: 400;\"> in a workflow that is executed on the same runner. Each step is either a shell script that will be executed, or an <\/span>action<span style=\"font-weight: 400;\"> that will be run. Steps are executed in order and are dependent on each other. Since each step is executed on the same runner, you can share data from one step to another. For example, you can have a step that builds your application followed by a step that tests the application that was built.<\/span><\/p>\n<p><strong>4. Action<\/strong> &#8211;\u00a0<b><\/b><span style=\"font-weight: 400;\">An <\/span><span style=\"font-weight: 400;\">action<\/span><span style=\"font-weight: 400;\"> is a custom application for the GitHub Actions platform that performs a complex but frequently repeated task. An action can pull your git repository from GitHub, set up the correct toolchain for your build environment, or set up the authentication to your cloud provider.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>5. Runner &#8211; <\/strong>A runner is a server that runs your workflows when they&#8217;re triggered. Each runner is a fresh, newly allocated virtual machine. GitHub provides Ubuntu Linux, Microsoft Windows, and macOS runners to run your workflows; Each runner can run a single job at a time.<br \/>\n<\/span><\/p>\n<h2><strong><br \/>\nExample of a workflow file:<\/strong><\/h2>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60186 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.01.47\u202fPM-1024x728.png\" alt=\"\" width=\"625\" height=\"444\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.01.47\u202fPM-1024x728.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.01.47\u202fPM-300x213.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.01.47\u202fPM-768x546.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.01.47\u202fPM-1536x1091.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.01.47\u202fPM-624x443.png 624w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-3.01.47\u202fPM.png 1866w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<h2><strong>How to create a workflow file?<\/strong><\/h2>\n<p>You have to create a .github\/workflows folder in your project root folder. Create your workflow as a YAML file inside that workflow folder.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60185\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-2.59.27\u202fPM-233x300.png\" alt=\"\" width=\"336\" height=\"433\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-2.59.27\u202fPM-233x300.png 233w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-01-28-at-2.59.27\u202fPM.png 520w\" sizes=\"(max-width: 336px) 100vw, 336px\" \/><\/p>\n<h2><strong>How to run a GitHub workflow?<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">You don&#8217;t need to run a workflow manually. Based on a given event trigger, the workflow will start to run automatically and execute the commands defined in that workflow.<\/span><\/p>\n<h2><strong>How to check the status of the running workflow?<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">You can see all your workflows running on the GitHub website itself.<\/span><\/p>\n<p>:<img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-60188 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-02-01-at-2.23.51\u202fAM-1024x495.png\" alt=\"\" width=\"625\" height=\"302\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-02-01-at-2.23.51\u202fAM-1024x495.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-02-01-at-2.23.51\u202fAM-300x145.png 300w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-02-01-at-2.23.51\u202fAM-768x371.png 768w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-02-01-at-2.23.51\u202fAM-1536x742.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-02-01-at-2.23.51\u202fAM-2048x990.png 2048w, \/blog\/wp-ttn-blog\/uploads\/2024\/02\/Screenshot-2024-02-01-at-2.23.51\u202fAM-624x301.png 624w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<h2><strong>Workflow templates<\/strong><\/h2>\n<p><span style=\"font-weight: 400;\">If you are thinking about writing your first workflow from scratch, then GitHub already offers a huge collection of mostly used workflows for different requirements. <\/span><span style=\"font-weight: 400;\">You can see all available workflow templates here: <a href=\"https:\/\/github.com\/actions\/starter-workflows\">https:\/\/github.com\/actions\/starter-workflows<\/a><\/span><\/p>\n<p><strong>Now, create your first workflow &amp; start using GitHub Actions for your software development workflow.<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">Best of luck!<\/span><\/p>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>Introduction Github Actions is an automation platform that is provided by Github. Using Github Actions, you can Automate, customize, and execute your software development workflows in your GitHub repository. GitHub Actions is a continuous integration and continuous delivery (CI\/CD) platform that allows you to automate your build, test, and deployment pipeline. You can create workflows [&hellip;]<\/p>\n","protected":false},"author":1211,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":55},"categories":[3429,1994,1],"tags":[5184,5627,5536],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/60189"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1211"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=60189"}],"version-history":[{"count":2,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/60189\/revisions"}],"predecessor-version":[{"id":60230,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/60189\/revisions\/60230"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=60189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=60189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=60189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}