프로젝트 중 무중단 배포 필요성을 느껴 ci/cd 구축을 해봤습니다. 

여러 블로그에 리눅스, 우분투 혼용해서 설정한 정보글이 많기도 하고,

java코드는 기록이 남지만 aws ubuntu , S3, codedeploy 설정은 기록이 안남아서 까먹을 까봐 찾아본 정보를 기록합니다.

 

Github Action CI 구축하기

 

repository에 들어가서  Actions 탭에 있는 Java with Gradle를 선택하여 

 

 

gradle.yml 파일을 만듭니다.

 

 

 

gradle.yml 파일을 아래와 같이 설정하고 push해보면 build 결과 테스트가 가능합니다.

(지금 사용하는 ubuntu는 20.04버전)

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]


jobs:
  build:
    runs-on: ubuntu-20.04

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8

      - name: Grant execute permission for gradlew
        run: chmod +x gradlew
        shell: bash

      - name: Build with Gradle
        run: ./gradlew build
        shell: bash

 

 

repository -> action탭에서 build 테스트 결과

github action을 통한 CI구축 완료

 

 

 

Github :  https://github.com/Jemoo1060/cicdPractice

 

GitHub - Jemoo1060/cicdPractice

Contribute to Jemoo1060/cicdPractice development by creating an account on GitHub.

github.com

 

출처 : https://shinsunyoung.tistory.com/120

출처 : https://www.sunny-son.space/AWS/AWS%20CodeDeploy%EC%99%80%20nginx%EB%A1%9C%20%EB%AC%B4%EC%A4%91%EB%8B%A8%20%EB%B0%B0%ED%8F%AC/

출처 : https://stalker5217.netlify.app/devops/github-action-aws-ci-cd-1/

복사했습니다!