1. Github 의 Cloud DevOps CI/CD
이전에 간단히 Github의 Action을 간단히 소개했는데, 관련부분에 대해 좀 자세히 기술하도록 하겠다.
Github의 변경사항 정리
이전 Github의 최근 변경사항 정리
1.1 Github Action 제한과요금제
일단 Free 요금제도, 현재 거의 마음대로 사용가능한 것 같으며, 다만 시간과 각 부분이 제한이 있을 뿐이다.
Build 와 Deploy를 매번 할 필요도 없거니와, Free 요금제로도 현재는 IoT는 거의 쓸만한 것 같다.
다만 아래의 제한과 요금제를 반드시 확인하며, Github의 정책이 변경될지 모르니, 수시로 확인
- Github Acton 의 제한 과 요금제
현재 달마다 갯수로 제한을 하며, 각 요금제에 따라 반드시 확인
1.2 Github Action 사용량 확인
Github Action을 사용하면 각 사용부분을 확인하도록 하자
- Github 본인계정으로 Action 량 확인
Github 본인 계정으로 Login 후, Setting-> Billing and Plans
> Github Action 사용량확인
Action , Package 뿐만 아니라, 각 Codespace 비롯하여 각 부분 사용량이 나옴
> Github Action 제한방법
아래 Payment를 설정안하면, Action 부분도 설정못하므로 의미가 없음
> 유료로 Github Action 사용할 경우, Payment 설정
나의 경우는 설정안함
2. Github의 Action 이란
DevOps 의 CI/CD 하면 요즘 Cloud 기반으로 하는데, Github Action 역시 Runner(Virtual Machine) 기반으로 Cloud 사용하는 것 같다.
이전에는 주로 나의 경우, CI/CD 이용한다면, Local/Cloud/Remote 기반이면 Jenkins or 무료/유료 Cloud기반이라면, CircleCI 많이 이용 했을 것이다.
이제는 Github에서 제공하는 Github Action로도 CI/CD 간단한 것들은 이곳에서 해도 괜찮은 것 같다.
참고로, 이번에 CircleCI 로그인하니, 기능변경이 너무 많이 되어졌으며, 변경사항을 새로 알아야 할 것으로 생각되어진다.
CircleCI로 사용할지도 다시 생각해야함(현재 무료사용자)
- Github Action 설명
Github Action 부분은 Github에서 자세한 설명이 있으므로, 이것만 읽어도 알것이라 생각됨
- Github Action 전체구조
기존에 사용하던, 다른 Script와 거의 유사하지만, 아래와 같이 Event를 별도로 정의하는게 가장 큰 특징으로 보인다.
Cloud이므로, Virtual Machine 기반으로 각 사용하여 동작하며, 더불어 Docker까지 확장하여 사용가능하다.
- Event : Github의 Webhook로 Git에 대한 Event Callback
- Runner1: Flowchart기반으로 각 실행1 진행
- Runner2: Flowchart기반으로 각 실행1 진행
![]() |
https://docs.github.com/ko/actions/learn-github-actions/understanding-github-actions |
- Github Action 전체예제
자세히 설명을 해주어서, 내가 구지 설명을 해야할 정도로 쉽다.
2.1 각 YAML Script 내부 필수 정보(workflow)
Github에서 너무 자세히 설명해주어서, 내가 구지 설명을 안해도 될 거 같아 필요부분만 링크를 한다.
각 Github Repository에 .github/workflow/xxxx.yml 로 Script을 구성하면된다.
- Github Action의 Workflow 기본적인 사용방법
Github Action을 만들때, Workflow 기본적으로 작성법
- Github Action 내부에서 사용되어지는 context
반드시 봐야하며, 각 YAML Script에서 사용되어지는 구문이므로 확인
- Github Action 내부 환경변수 사용
Linux shell 에서 보통 많이 사용
2.2 Action Event 기능
이 부분은 이전에는 Webhook를 이용하여 사용하였는데, Github Action Script에서 쉽게 정의가 가능하다.
간단히 설명하면 다음과 같으며 주로 많이 사용할 것이 아마 Git Event일 것이다.
- Git 의 관련된 Event
- Github 의 Issue Event
- Github 의 label Event
- 기타 등등
- Webhook 관련내용
일반적으로 Webhook는 주로 많이 볼 수 있는 것이 AWS Lamda 와 Github Webhook일 것 같다.
Event가 일어날 경우, 이를 알려주는 API로 많이 사용되어지며, 아래의 내용을 참고하자.
- Github Action 의 Event 기능
Event를 사용하는 다양한 방법을 소개하며, 상위의 Webhook의 기능이라고 볼수 있다.
- Github Single Event 실제예제 분석
상위 두 개 조건(branches/tags)을 And 연산하지 않고 OR 연산하여 동작하며, 이를 Filter 라고 함
- Push 후 branches 이름 확인
- Push 후 tags 이름 확인
on: push: # Sequence of patterns matched against refs/heads branches: - main - 'mona/octocat' - 'releases/**' # Sequence of patterns matched against refs/tags tags: - v2 - v1.*
- Github Action 다양한 각 Event 동작 예제들
상위 내용은 workflow-trigger 전체설명
Single Event 와 Multiple Events (e.g. push, fork, pull_request)
Filter 역할로 include 로 포함하여 OR연산으로 동작 (상위와 동일)
Filter 역할로 exclude 로 제외도 가능(e.g. branches-ignore, paths-ignore)
Github Action 다양한 확장 Event 기능
다양한 Event Trigger 제공해고 있으며, 다 사용해보지 못했지만, 대충 이해가능
2.3 Github Action 실제사용 예
나의 경우, 간단히 테스트를 위해서 사용했으며, 잘 동작되는 것을 확인하였다.
Event는 Github에 Push 될때, Tag가 있을 경우에만 동작하도록 함
즉 Release 목적으로만 만들었으며, 사실 오직 Github Action 테스트 하기 위해서 만듦
좀 더 고급스럽게 하며 Docker 기반으로 하면 된다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: myrelease-LoRa Gateway Build-Release (Push with Tag) | |
# | |
# Git push event trigger | |
# | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions | |
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows | |
# every push | |
# on: [push] | |
# | |
on: | |
push: | |
# Sequence of patterns matched against refs/tags | |
tags: | |
- 'v*' # Push events to matching v*, i.e. v5.1.2 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# | |
# Help | |
# - https://github.com/actions/checkout | |
# | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Build Lora Gateway | |
run: | | |
pwd | |
echo "Start to build Lora Gateway" | |
make all | |
mkdir -p output | |
cp -a libloragw/libloragw.a ./output/ | |
cp -a util_pkt_logger/util_pkt_logger ./output/ | |
cp -a util_spi_stress/util_spi_stress ./output/ | |
cp -a util_tx_test/util_tx_test ./output/ | |
cp -a util_lbt_test/util_lbt_test ./output/ | |
cp -a util_tx_continuous/util_tx_continuous ./output/ | |
cp -a util_spectral_scan/util_spectral_scan ./output/ | |
zip --junk-paths -r loragateway output | |
# | |
# Help | |
# - https://github.com/actions/upload-artifact | |
# | |
- name: Upload a Build Artifact | |
uses: actions/upload-artifact@v3.0.0 | |
with: | |
# Artifact name | |
name: LoRaLib | |
path: | | |
./output | |
retention-days: 90 | |
# | |
# Help | |
# - https://github.com/actions/create-release | |
# | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
body: | | |
Changes in this Release | |
- First Change | |
- Second Change | |
draft: false | |
# | |
# Help | |
# - https://github.com/actions/upload-release-asset | |
# | |
- name: Add Release asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./loragateway.zip | |
asset_name: loragateway.zip | |
asset_content_type: application/zip |
2.4 Github Action 실행동작 및 결과
실제로 사용해보니, 꽤 좋으며, 확장하여 Docker기반으로도 사용가능하다.
- Github Virtual Machine 확인
- Github Action 진행과정
Github Action에서 자동으로 CI가 진행 된 후 CD가 됨
- Github Action 의 결과확인
자동으로 Release가 되며, 상위 Script에서 내가 또 별도의 File도 추가하였다.
아래와 같이 Github Action으로 되었다고 하며,
내가 원하는 대로, 각 정도도 포함되어있으며, Assets도 별도로 추가한대로 추가되어져 있다.
댓글 없음 :
댓글 쓰기