{"id":33071,"date":"2024-11-01T09:13:33","date_gmt":"2024-11-01T09:13:33","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=33071"},"modified":"2024-11-01T11:29:05","modified_gmt":"2024-11-01T11:29:05","slug":"spring-boot-backend-development-course-writing-github-action-scripts-cd","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/33071\/","title":{"rendered":"Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD"},"content":{"rendered":"<h2>Writing GitHub Action Scripts: Continuous Deployment (CD)<\/h2>\n<p>In modern software development, Continuous Deployment (CD) and Continuous Integration (CI) are essential elements. Automating these processes can significantly enhance developer productivity, especially when developing backend applications using Spring Boot. In this tutorial, we will explore how to automatically deploy a Spring Boot application using GitHub Actions.<\/p>\n<h3>1. What is Spring Boot?<\/h3>\n<p>Spring Boot is an open-source framework that extends the Spring Framework, making it easier to develop standalone Spring applications. It provides several useful features that simplify and expedite the use of the existing Spring Framework. Notably, it reduces the burden of initial setup and supports rapid application execution through built-in servers (e.g., Tomcat, Jetty).<\/p>\n<h3>2. What is GitHub Actions?<\/h3>\n<p>GitHub Actions is a CI\/CD tool provided by GitHub that detects changes in the code and allows tasks to be executed automatically. Users can define and manage workflows in YAML file format, which can be triggered by various events (push, issue creation, etc.). This allows for the automation of tasks such as testing, building, and deployment.<\/p>\n<h3>3. Prerequisites<\/h3>\n<ul>\n<li>You should have already developed or created a Spring Boot application.<\/li>\n<li>You need to create a GitHub repository for the project.<\/li>\n<li>A GitHub account is required to use GitHub Actions.<\/li>\n<\/ul>\n<h3>4. Creating a Spring Boot Application<\/h3>\n<p>To create a Spring Boot application, you can use <a href=\"https:\/\/start.spring.io\/\">Spring Initializr<\/a>. Set the appropriate meta information and add necessary dependencies to download the project. For example, you can select web (application), JPA, and H2 database.<\/p>\n<pre><code> \n\/\/ Example Maven dependency (pom.xml)\n&lt;dependencies&gt;\n    &lt;dependency&gt;\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n        &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;\n    &lt;\/dependency&gt;\n    &lt;dependency&gt;\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n        &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;\/artifactId&gt;\n    &lt;\/dependency&gt;\n    &lt;dependency&gt;\n        &lt;groupId&gt;com.h2database&lt;\/groupId&gt;\n        &lt;artifactId&gt;h2&lt;\/artifactId&gt;\n        &lt;scope&gt;runtime&lt;\/scope&gt;\n    &lt;\/dependency&gt;\n&lt;\/dependencies&gt;\n<\/code><\/pre>\n<h3>5. Creating a GitHub Repository<\/h3>\n<p>Access GitHub and create a new repository. Set the repository name according to the project, and you may select the &#8216;Initialize this repository with a README&#8217; option. Then, push your local project to the GitHub repository.<\/p>\n<pre><code>\n# Run in the local project directory\ngit init\ngit add .\ngit commit -m \"Initial commit\"\ngit branch -M main\ngit remote add origin https:\/\/github.com\/username\/repository.git\ngit push -u origin main\n<\/code><\/pre>\n<h3>6. Writing a GitHub Actions Workflow<\/h3>\n<p>Now you need to create a GitHub Actions workflow file. Create a YAML file under the `.github\/workflows` directory. For example, create a file named `ci.yml` and write the following:<\/p>\n<pre><code>\nname: CI\n\non:\n  push:\n    branches:\n      - main\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Check out code\n        uses: actions\/checkout@v2\n\n      - name: Set up JDK 11\n        uses: actions\/setup-java@v2\n        with:\n          java-version: '11'\n          distribution: 'adopt'\n\n      - name: Build with Maven\n        run: mvn clean package\n<\/code><\/pre>\n<h3>7. Writing the Deployment Workflow<\/h3>\n<p>After setting up the basic CI workflow, it is time to write the workflow for CD. Here, we will describe the process of deploying to AWS EC2 as an example. Create a new YAML file named `deploy.yml` and write the following:<\/p>\n<pre><code>\nname: Deploy to EC2\n\non:\n  push:\n    branches:\n      - main\n\njobs:\n  deploy:\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: Check out code\n        uses: actions\/checkout@v2\n\n      - name: Set up JDK 11\n        uses: actions\/setup-java@v2\n        with:\n          java-version: '11'\n          distribution: 'adopt'\n\n      - name: Build with Maven\n        run: mvn clean package\n\n      - name: Deploy to EC2\n        uses: appleboy\/scp-action@master\n        with:\n          host: ${{ secrets.EC2_HOST }}\n          username: ${{ secrets.EC2_USER }}\n          key: ${{ secrets.EC2_SSH_KEY }}\n          port: 22\n          source: target\/*.jar\n          target: \/path\/to\/deploy\/\n<\/code><\/pre>\n<p>The `appleboy\/scp-action` used here helps send files to the EC2 instance using SSH. Each item can be stored in GitHub Secrets to enhance security.<\/p>\n<h3>8. Setting Up GitHub Secrets<\/h3>\n<p>You now need to set up secret variables used in the CI\/CD workflow. Go to the &#8216;Settings&#8217; -&gt; &#8216;Secrets and variables&#8217; -&gt; &#8216;Actions&#8217; of the GitHub repository page and add the secret variables to be hidden. For example:<\/p>\n<ul>\n<li><strong>EC2_HOST<\/strong>: IP address of the EC2 instance<\/li>\n<li><strong>EC2_USER<\/strong>: SSH username<\/li>\n<li><strong>EC2_SSH_KEY<\/strong>: SSH private key<\/li>\n<\/ul>\n<h3>9. Checking GitHub Actions Execution<\/h3>\n<p>Once all configurations are complete, commit and push to the main branch of the repository. This will automatically trigger GitHub Actions, executing the configured CI\/CD process. You can check the execution logs in the &#8216;Actions&#8217; tab to verify the success of each step.<\/p>\n<h3>10. Conclusion<\/h3>\n<p>In this tutorial, we learned how to automatically deploy a Spring Boot backend application using GitHub Actions. GitHub Actions allows you to set up CI\/CD processes with just a simple YAML file, making it a powerful tool for automating various tasks. This can enhance developer productivity and improve the reliability of deployments. Additionally, you might consider extensions such as integrating with other cloud providers or deploying with Docker.<\/p>\n<h2>References<\/h2>\n<ul>\n<li><a href=\"https:\/\/spring.io\/projects\/spring-boot\">Official Spring Boot Documentation<\/a><\/li>\n<li><a href=\"https:\/\/docs.github.com\/en\/actions\">Official GitHub Actions Documentation<\/a><\/li>\n<li><a href=\"https:\/\/docs.aws.amazon.com\/AWSEC2\/latest\/UserGuide\/EC2_GetStarted.html\">Getting Started with AWS EC2<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Writing GitHub Action Scripts: Continuous Deployment (CD) In modern software development, Continuous Deployment (CD) and Continuous Integration (CI) are essential elements. Automating these processes can significantly enhance developer productivity, especially when developing backend applications using Spring Boot. In this tutorial, we will explore how to automatically deploy a Spring Boot application using GitHub Actions. 1. &hellip; <a href=\"https:\/\/atmokpo.com\/w\/33071\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[131],"tags":[],"class_list":["post-33071","post","type-post","status-publish","format-standard","hentry","category-spring-boot-backend-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/33071\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Writing GitHub Action Scripts: Continuous Deployment (CD) In modern software development, Continuous Deployment (CD) and Continuous Integration (CI) are essential elements. Automating these processes can significantly enhance developer productivity, especially when developing backend applications using Spring Boot. In this tutorial, we will explore how to automatically deploy a Spring Boot application using GitHub Actions. 1. &hellip; \ub354 \ubcf4\uae30 &quot;Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/33071\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:13:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:29:05+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/33071\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33071\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD\",\"datePublished\":\"2024-11-01T09:13:33+00:00\",\"dateModified\":\"2024-11-01T11:29:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33071\/\"},\"wordCount\":597,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Spring Boot backend development\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/33071\/\",\"url\":\"https:\/\/atmokpo.com\/w\/33071\/\",\"name\":\"Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:13:33+00:00\",\"dateModified\":\"2024-11-01T11:29:05+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33071\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/33071\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/33071\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/33071\/","og_locale":"ko_KR","og_type":"article","og_title":"Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Writing GitHub Action Scripts: Continuous Deployment (CD) In modern software development, Continuous Deployment (CD) and Continuous Integration (CI) are essential elements. Automating these processes can significantly enhance developer productivity, especially when developing backend applications using Spring Boot. In this tutorial, we will explore how to automatically deploy a Spring Boot application using GitHub Actions. 1. &hellip; \ub354 \ubcf4\uae30 \"Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD\"","og_url":"https:\/\/atmokpo.com\/w\/33071\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:13:33+00:00","article_modified_time":"2024-11-01T11:29:05+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/33071\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/33071\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD","datePublished":"2024-11-01T09:13:33+00:00","dateModified":"2024-11-01T11:29:05+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/33071\/"},"wordCount":597,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Spring Boot backend development"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/33071\/","url":"https:\/\/atmokpo.com\/w\/33071\/","name":"Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:13:33+00:00","dateModified":"2024-11-01T11:29:05+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/33071\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/33071\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/33071\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Spring Boot Backend Development Course, Writing GitHub Action Scripts, CD"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=33071"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33071\/revisions"}],"predecessor-version":[{"id":33072,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33071\/revisions\/33072"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=33071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=33071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=33071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}