teamdable / vv-deploy-actions

1 stars 0 forks source link
vision-valley

vv-deploy-actions

vv-deploy-actions는 edge device에 소스 코드 배포와 프로세스 재시작하는 작업을 reusable workflow로 제공한다. \ ⚠️ warning ⚠️ 해당 repository는 public으로 관리되므로, commit시 주의하도록 한다.

Contents

  1. Deploy Actions: 소스 코드 배포 작업을 제공
    1. Variables: deploy-actions 사용시 필요한 변수들
    2. Usage: deploy-actions 사용법
    3. Example: deploy-actions 사용 예시
  2. Restart Actions: edge device에서의 프로세스 재시작 작업을 제공
    1. Variables: restart-actions 사용시 필요한 변수들
    2. Example: restart-actions 사용 예시
  3. Parallel Deployment (NEW)`: 배포장비를 입력받아 연속적으로 배포를 제공
    1. Variables: Parallel Deployment 사용시 필요한 변수들
    2. Usage : Parallel Deployment 사용법
    3. Example : Parallel Deployment 사용 예시

      deploy-actions

      Variables

      배포하려는 소스코드의 repository에서 vv-deploy-actions의 reusable workflow를 활용할 때, 필요한 변수들에 대한 설명은 아래에서 확인한다.

Input variables

Secrets Variables


Usage

vv-deploy-actions의 reusable workflow를 활용할 때, 별도의 clone, install 작업은 필요하지 않다.

배포하려는 소스코드의 repository에서는 workflow파일에서 vv-deploy-actions의 reusable workflows를 호출한다. ( 아래의 1번, 2번 과정을 따른다. )

  1. bin/deploy/install-settings.sh, bin/deploy/vpn-config.ini 파일들이 필요하다. 예시는 example/에서 확인할 수 있다.

  2. .github/workflows/your-workflow-name.yml를 작성한다. 예시는 아래에서 확인할 수 있다.

    name: Continuous Deploy
    on: push
    
    jobs:
    job-name:
      uses: teamdable/vv-deploy-actions/.github/workflows/deploy-to-edge-devices.yml@main
      with:
        user: '$USERNAME'
        code-name: '$CODE_NAME'
        parent-dir: '$PARENT_DIR'
        version-file-name: '$VERSION_FILE'
        exclude-files-from-zip: '$EXCLUDE_FILE'
        slack-channel: '$SLACK_CHANNEL'
      secrets:
        password: ${{ secrets.PASSWORD }}
        otp: ${{ secrets.OTP }}

    output:

    Build - Success ``` deleting: .github/ deleting: .github/workflows/ deleting: .github/workflows/main-cd.yml ```
    Deploy & Install - All success: 모든 HOST에 성공적으로 배포되면, 정상적으로 종료됩니다. ``` hostname: 127.0.0.1 build & deploy Success install Success hostname: 127.0.0.2 build & deploy Success install Success hostname: 127.0.0.3 build & deploy Success install Success Deploy와 Install에 모두 성공하였습니다 ``` - Fail: 모든 HOST에 배포를 진행하고, 과정이 완료된 후에 하나라도 배포가 실패했을 시에 Actions가 실패합니다. ``` hostname: 127.0.0.2 build & deploy Success [err] target version과 source version이 일치하지않습니다 hostname: 127.0.0.3 [err] 배포 대상 edge device에 deploy 작업이 제대로 이루어지지않았습니다 Deploy와 Install에 실패한 기기들의 hostname은 다음과 습니다 Deploy: 127.0.0.3 Install: 127.0.0.2 127.0.0.3 ```

Example

1. 프로세스 모니터링 모듈을 배포대상 장비의 ~/monitoring/process로 배포

2. inference 모듈을 배포대상 장비의 ~/inference 위치에 배포

uses: teamdable/vv-deploy-actions/.github/workflows/deploy-to-edge-devices.yml@main
with:
    user: 'ubuntu'
!   code-name: 'inference'
!   deploy-branch: ${GITHUB_REF##*/} 
!   parent-dir: '/home/ubuntu/'
!   version-file-name: '_version.py'
-   exclude-files-from-zip: 'bin/deploy/vpn-config.ini'
+   
!   slack-channel: 'general'
secrets:
    password: ${{ secrets.PASSWORD }}
    otp: ${{ secrets.OTP }}

restart-actions

Variables

배포하려는 소스코드의 repository에서 vv-deploy-actions의 reusable workflow를 활용할 때, 필요한 변수들에 대한 설명은 아래에서 확인한다.

Input variables

Secrets Variables


Example

inference 프로세스를 재시작

name: Restart After Deployment

on:
  # manually trigger
  workflow_dispatch:

jobs:
  restart-process-in-edge:
    uses: teamdable/vv-deploy-actions/.github/workflows/restart_process_after_deploy.yml@main
    with:
      user: 'ubuntu'
!     process-name: 'inference'
!     slack-channel: 'general'
    secrets:
      password: ${{ secrets.PASSWORD }}
      otp: ${{ secrets.OTP }}

parallel-deployment

Variables

Input variables

deploy-actions의 input, secret 변수와 모두 동일하나 process-name이 추가된다

Example

배포하려는 소스코드의 repository에서는 workflow파일에서 vv-deploy-actions의 reusable workflows를 호출한다. ( 아래의 1번, 2번 과정을 따른다. )

  1. bin/deploy/install-settings.sh 파일을 작성한다. 예시는 example/에서 확인할 수 있다.
  2. .github/workflows/your-workflow-name.yml를 작성한다. 예시는 아래에서 확인할 수 있다.

    name: Parallel Deployment
    
    on:
      workflow_dispatch:
        inputs:
          deploy-target-devices:
            description: '배포할 device_id를 입력하세요 (SN1-001, SN1-002 ... )'
            required: true
            type: string
          deploy-message:
            description: '배포 내용/유의사항 등을 입력하세요'
            required: true
            type: string
    jobs:
      CD:
        uses: teamdable/vv-deploy-actions/.github/workflows/deployment-with-restart.yml@main
        with:
          deploy-target-device: ${{ github.event.inputs.deploy-target-devices }}
          user: 'ubuntu'
          code-name: 'resource'
          deploy-branch: ${GITHUB_REF##*/}
          parent-dir: '/home/ubuntu'
          version-file-name: '_version.py'
          exclude-files-from-zip: 'bin/deploy/vpn-config.ini'
          slack-channel: 'general'
          process-name: 'resource-monitoring'
          deploy-message: ${{ github.event.inputs.deploy-message }}
        secrets:
          password: ${{ secrets.REMOTE_PASSWD }}
          otp: ${{ secrets.GOOGLE_KEY }}