Skip to Content
가이드통합하기GHCR 프라이빗 이미지

GHCR 프라이빗 이미지 배포

GHCR 이미지 배포에 필요한 정보와 임시 인증 정보를 GitHub Actions에서 workflow params로 전달하는 예제예요.
Deplite는 Agent 이름·workflow 이름과 params를 전달하고, 실제 동작은 노드 로컬 YAML과 스크립트에서 정의해요.
노드에서 실행할 스크립트는 프로젝트 환경에 맞게 준비해주세요.

흐름은 다음과 같아요.

  1. GitHub Actions가 이미지를 빌드하고 GHCR에 올려요.
  2. GitHub Actions가 POST /v1/run/{agentName}/{workflowName}으로 이미지 정보와 GITHUB_TOKEN을 전달해요.
  3. Agent는 로컬 YAML에서 허용한 스크립트를 실행하고, 스크립트가 전달된 params를 사용해요.

GitHub Actions job이 끝나면 GITHUB_TOKEN이 만료돼요.
Run Action은 기본으로 기기 workflow가 끝날 때까지 기다리므로, GHCR pull이 끝나는 동안 Actions job을 유지할 수 있어요.
Run Action의 기본 대기 제한은 60분이며 wait-timeout-minutes로 조정할 수 있어요.

1. Agent workflow 작성

Agent의 기본 workflow 디렉토리에 다음 YAML을 추가해주세요.
배포 스크립트는 Agent 실행 사용자 권한으로 실행돼요.

name: deploy-myapp on: webhook: refs: [main] params: - name: image type: string required: true - name: ghcr_user type: string required: true - name: ghcr_token type: string required: true steps: - name: deploy run: ./scripts/deploy-from-ghcr.sh

Workflow params는 step에서 DEPLITE_PARAM_ 접두사가 붙은 환경변수로 사용할 수 있어요.
위 예제에서는 DEPLITE_PARAM_IMAGE, DEPLITE_PARAM_GHCR_USER, DEPLITE_PARAM_GHCR_TOKEN으로 전달돼요.
스크립트가 토큰 값을 로그에 출력하지 않도록 주의해주세요.

params를 선언하면 선언한 키만 요청을 통과해요.
선언한 키가 빠지거나 스키마와 다른 값이 오면 실행 요청이 거절돼요.

2. workflow 권한 토큰 발급

콘솔에서 해당 Agent의 workflow 화면을 열고 workflow 권한 토큰을 발급해주세요.
발급한 토큰은 GitHub 저장소의 Settings → Secrets and variables → Actions에서 DEPLITE_API_TOKEN으로 저장해주세요.
Agent 이름과 workflow 이름은 Actions Variables에 DEPLITE_AGENT_NAME, DEPLITE_WORKFLOW_NAME으로 저장해주세요.

3. GitHub Actions에서 workflow 실행

Private package를 읽는 GitHub Actions job에는 packages: read 권한이 필요해요.
아래 예제는 run-action으로 workflow 이름과 params를 전달해요.
ref를 생략하면 현재 브랜치·태그의 짧은 이름을 사용하므로 on.webhook.refs에 선언한 범위와 맞춰주세요.

name: Deploy on: push: branches: [main] permissions: contents: read packages: read jobs: deploy: runs-on: ubuntu-latest steps: - name: Run Deplite workflow uses: Deplite/run-action@v0 with: api-token: ${{ secrets.DEPLITE_API_TOKEN }} agent: ${{ vars.DEPLITE_AGENT_NAME }} workflow: ${{ vars.DEPLITE_WORKFLOW_NAME }} params: >- {"image":"ghcr.io/${{ github.repository }}:${{ github.sha }}","ghcr_user":"${{ github.actor }}","ghcr_token":"${{ secrets.GITHUB_TOKEN }}"}

Run Action은 workflow가 끝날 때까지 기다려 GHCR pull이 완료된 뒤 Actions job이 끝나도록 해요.
기본 대기 시간 60분 안에 끝나지 않으면 wait-timeout-minutes를 조정해주세요.
직접 REST API를 호출하는 curl 방식은 POST https://api.deplite.io/v1/run/{agent}/{workflow&#125 ;에 ref, params, wait를 담아 요청해요.
직접 API의 waitTimeoutMs는 최대 5분이며, 요청 본문은 워크플로우 실행 API를 참고해주세요.

curl --fail-with-body -sS -X POST \ "https://api.deplite.io/v1/run/prod-agent/deploy" \ -H "Authorization: Bearer $DEPLITE_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"ref":"main","wait":true,"params":{"image":"ghcr.io/acme/my-app:1.2.3","ghcr_user":"octocat","ghcr_token":"<GITHUB_TOKEN>"}}'

관련 문서

최종 수정 일자: