-
[CI] Github Action으로 Docker hub에 이미지 업로드 #1코딩/CI.CD 2023. 3. 10. 02:36
목표
master branch에 code가 push 되었을 때 Github Action을 통해서 Docker hub에 이미지를 빌드하여 푸쉬
github workflow 작성하기
Github Action은 트리거가 발생하면 repository의 root 디렉토리 밑에
.github/workflow
의 yaml 파일을 읽어서 동작합니다. 링크GitHub Actions 빠른 시작 - GitHub Docs
Introduction You only need a GitHub repository to create and run a GitHub Actions workflow. In this guide, you'll add a workflow that demonstrates some of the essential features of GitHub Actions. The following example shows you how GitHub Actions jobs can
docs.github.com
여기서 트리거는 repository에서 발생되는 이벤트를 의미합니다. 링크
GitHub Actions 이해 - GitHub Docs
Overview 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 deplo
docs.github.com
여러가지 트리거로 action을 실행시킬 수 있지만 이번 포스트에서는 master branch에 push 이벤트가 발생했을 때 발생시키는게 목적입니다.
깃액션을 이해하기 위해선 우선 runner에 대해서 이해하고 넘어가시면 좋다고 생각합니다.깃액션에 지정된 트리거를 감지했을 때 실행되는 서버입니다. 커스텀도 가능하지만 기본적으로 다양한 OS를 깃헙에서 제공하기 때문에 그대로 이용하시는것을 추천합니다.(Ubuntu Linux, Microsoft Windows, and macOS)
각 항목에 대한 간단한 설명입니다.- name : Action 탭에 표시되는 workflow 이름
- run-name : Action 실행 후 workflow에 의해 만들어지는 workflow 이름
- on : 트리거 설정
- job: job 설정
- job은 하나의 runner에서 실행되는 step의 집합(하나의 모음집)
- runs-on : runner 설정
- steps: jobs 안에서 실행 시킬 job 목록들
- uses: 정의된 액션을 사용합니다.
- run : runner에서 실행할 명령어
CI_master_push.yaml 작성
name: CI master push # optional run-name: ${{ github.actor }} pushed to master branch. 🚀 # optional on: push: # required branches: - master jobs: build: # job 식별자 runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build run: | echo "Build" - name: Test run: | echo "Test" - name: Deploy run: | echo "Deploy"
master branch에 code push가 되었을 경우 workflow가 잘 동작된 것을 확인 할 수 있다.
다음 포스트에서는 Github Action으로 docker 이미지 빌드를 수행하는 과정을 담아 보겠습니다.
https://yourknow.tistory.com/48
[CI] Github Action으로 Docker hub에 이미지 업로드 #2
더보기 https://yourknow.tistory.com/47 1편 - gitaction workflow 예제를 작성해보는 포스트 [CI] Github Action으로 Docker hub에 이미지 업로드 #1 목표 master branch에 code가 push 되었을 때 Github Action을 통해서 Docker hub
yourknow.tistory.com
참고문서
'코딩 > CI.CD' 카테고리의 다른 글
[CD] 5분만에 오픈소스를 활용한 Docker container 이미지 자동으로 배포하기(feat. watchtower) (0) 2023.05.25 [CI] Github Action으로 Docker hub에 이미지 업로드 #2 (0) 2023.03.14