{"id":2001,"date":"2022-06-25T12:00:00","date_gmt":"2022-06-25T10:00:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/what-is-github-action-how-to-set-set-it-up\/"},"modified":"2026-07-05T03:26:35","modified_gmt":"2026-07-05T01:26:35","slug":"what-is-github-action-how-to-set-set-it-up","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/what-is-github-action-how-to-set-set-it-up\/","title":{"rendered":"What Is Github Action \u2013 How to Set Set it Up"},"content":{"rendered":"<p>In this tutorial, you will understand Github action and how to set it up.<\/p>\n<p>We would create a simple Spring Boot application locally, build it and push it to Github. Then we would create a Github action that triggers the build anytime a push is made to the repository.<\/p>\n<p>Next, will show you how to use Super Linter to validate your code using Github actions.<\/p>\n<p>Lets follow the steps<\/p>\n<ol>\n<li><a href=\"#t1\">Create a SpringBoot Application and Push to Github<\/a><\/li>\n<li><a href=\"#t2\">Setup Java CI With Maven Workflow<\/a><\/li>\n<li><a href=\"#t3\">Github Action with Super Linter Workflow<\/a><\/li>\n<li><a href=\"#t4\">Multiple Operating Systems<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t1\">1. Create a Spring Application and Push to Github<\/strong><\/h4>\n<p><strong>Step 1<\/strong> &#8211; Create a new Spring Boot application.<\/p>\n<p><strong>Step 2<\/strong> &#8211; In the terminal, run the command<\/p>\n<p><em>mvn clean install<\/em><\/p>\n<p>And make sure the application builds successfully.<\/p>\n<p><strong>Step 3<\/strong> &#8211; Create a new Github repository and push the code to the repository.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. Setup Java CI With Maven Workflow<\/strong><\/h4>\n<p>What we would like to do is to setup GitHub actions. An action is a collection of Workflow where a workflow is a definition of the steps to perform when a given event occurs. A workflow is defined in a YAML file. But you don&#8217;t need to write this from the scratch. There&#8217;s already tons of pre-written workflows you can choose from and with very little adjustment, you can get it to give the desired result.<\/p>\n<p>Follow the steps below:<\/p>\n<p><strong>Step 1<\/strong> &#8211; Open your code repository in Github and click on the Actions tab as shown below<\/p>\n<figure id=\"attachment_14885\" aria-describedby=\"caption-attachment-14885\" style=\"width: 812px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2022\/06\/Screenshot-2022-06-25-at-21.30.42.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14885 size-full\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2022\/06\/Screenshot-2022-06-25-at-21.30.42.png\" alt=\"Github Actions tab\" width=\"812\" height=\"351\" srcset=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2022\/06\/Screenshot-2022-06-25-at-21.30.42.png 812w, https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2022\/06\/Screenshot-2022-06-25-at-21.30.42-300x130.png 300w, https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2022\/06\/Screenshot-2022-06-25-at-21.30.42-768x332.png 768w, https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2022\/06\/Screenshot-2022-06-25-at-21.30.42-600x259.png 600w\" sizes=\"auto, (max-width: 812px) 100vw, 812px\" \/><\/a><figcaption id=\"caption-attachment-14885\" class=\"wp-caption-text\">Github Actions tab<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p><strong>Step 2<\/strong> &#8211; In the list of Worflows, find &#8220;Java With Maven&#8221; as shown below ( you can also search using the search field). This workflow contains the template for building Java projects with Maven.<\/p>\n<figure id=\"attachment_14889\" aria-describedby=\"caption-attachment-14889\" style=\"width: 654px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2022\/06\/Screenshot-2022-06-25-at-23.38.35.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14889\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2022\/06\/Screenshot-2022-06-25-at-23.38.35.png\" alt=\"\" width=\"654\" height=\"307\" srcset=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2022\/06\/Screenshot-2022-06-25-at-23.38.35.png 654w, https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2022\/06\/Screenshot-2022-06-25-at-23.38.35-300x141.png 300w, https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2022\/06\/Screenshot-2022-06-25-at-23.38.35-600x282.png 600w\" sizes=\"auto, (max-width: 654px) 100vw, 654px\" \/><\/a><figcaption id=\"caption-attachment-14889\" class=\"wp-caption-text\">Java With Maven Workflow<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p><strong>Step 3<\/strong> &#8211; Click on Configure. This would display the workflow configuration file in yml. We could actually edit this file later. But for now it&#8217;s fine. Notice the structure of the file. The event that triggers the workflow is specified in the on: section. (<a href=\"https:\/\/youtu.be\/9G_z9iadAW0\" target=\"_blank\" rel=\"noopener\">I explain the rest in the video<\/a>). In this case, the workflow would trigger on:<\/p>\n<ul>\n<li>push<\/li>\n<li>pull request<\/li>\n<\/ul>\n<p><strong>Step 4<\/strong> &#8211; Click on the Start Commit button to commit this file. Note that a workflow file is actually placed inside your repository in a special directory &#8211; .github\/worflows\/&lt;file.yml&gt;. In our case, it is maven.yml.<\/p>\n<p><strong>Step 5<\/strong> &#8211; Now go back to your IDE. First do a pull to update your local repository. Then make some changes and push back to Github. You will notice that the workflow triggers and the build is run.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t3\">3. Github Action Using Super Linter Workflow<\/strong><\/h4>\n<p>Super Linter is a tool that you can use to check your code to make sure it is syntactically correct. Note that you can add multiple workflows. Now we would add the Super Linter workflow as a second workflow. Follow the steps<\/p>\n<p><strong>Step 1<\/strong> &#8211; Go to Action and click on <strong>New Workflow.<\/strong><\/p>\n<p><strong>Step 2<\/strong> &#8211; Search for Super Linter.<\/p>\n<p><strong>Step 3<\/strong>&#8211; Follow the same procedure to add the Super Linter workflow. Notice that once you commit, it triggers the existing workflow as well.<\/p>\n<p><strong>Step 4<\/strong> &#8211; Test out this workflow by pushing code with bug and see that it fails with a red mark.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t4\">4. Github Actions in Parallel on different OS<\/strong><\/h4>\n<p>If you notice, you see that the basic maven.yml file has as workflow that runs the build on ubuntu-latest. You can also adjust this to allow the build to run on multiple operating sytems in parallel.<\/p>\n<p>To do that, adjust the runs on section of the workflow file to include three operating systems like so;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">    runs-on: ${{matrix.os}}\r\n    strategy: \r\n      matrix:\r\n        os: [ubuntu-latest, windows-latest, macOS-latest]\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Once you do this, you can go ahead to modify your code in the IDE and push, you will notice that the three runs in parallel.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/youtu.be\/9G_z9iadAW0\" target=\"_blank\" rel=\"noopener\">Video tutorial on Working With Github Actions<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will understand Github action and how to set it up. We would create a simple Spring Boot application locally, build it &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[414],"tags":[],"class_list":["post-2001","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/2001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=2001"}],"version-history":[{"count":1,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/2001\/revisions"}],"predecessor-version":[{"id":2169,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/2001\/revisions\/2169"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=2001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=2001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=2001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}