본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

GitHub

원문 보기 위키 갱신

GitHub Apps를 사용해 커밋 상태(commit status)를 변경하는 GitHub 알림 서비스예요. 다음과 같은 설정을 지정해야 해요.

출처: 문서

본문

파라미터 (Parameters)

GitHub 알림 서비스는 GitHub Apps를 사용해 커밋 상태를 변경하며, 다음 설정을 지정해야 해요.

  • appID - 앱 id예요
  • installationID - 앱 설치 id예요
  • privateKey - 앱 개인 키(private key)예요
  • enterpriseBaseURL - 선택 사항 URL로, 예를 들어 https://git.example.com/api/v3이에요
  • maxIdleConns - 선택 사항이에요. 모든 호스트에 걸친 유휴(keep-alive) 연결의 최대 개수예요
  • maxIdleConnsPerHost - 선택 사항이에요. 호스트당 유휴(keep-alive) 연결의 최대 개수예요
  • maxConnsPerHost - 선택 사항이에요. 호스트당 총 연결의 최대 개수예요
  • idleConnTimeout - 선택 사항이에요. 유휴(keep-alive) 연결이 닫히기 전에 유지되는 최대 시간이에요

⚠️ 참고: argoproj/notifications-engine#205가 해결될 때까지 enterpriseBaseURL에 /api/v3을 지정해야 해요.

설정 (Configuration)

  • https://github.com/settings/apps/new 에서 GitHub Apps를 생성해요
  • 리포지토리 권한을 변경해 commit statuses 및/또는 deployments 및/또는 pull requests comments 쓰기를 활성화해요
  • 개인 키(private key)를 생성하고 자동으로 다운로드해요
  • 계정에 앱을 설치해요
  • argo-rollouts-notification-secret Secret에 privateKey를 저장하고 argo-rollouts-notification-configmap ConfigMap에서 GitHub 통합을 구성해요
apiVersion: v1
kind: ConfigMap
metadata:
  name: argo-rollouts-notification-configmap
data:
  service.github: |
    appID: <app-id>
    installationID: <installation-id>
    privateKey: $github-privateKey
apiVersion: v1
kind: Secret
metadata:
  name: <secret-name>
stringData:
  github-privateKey: |
    [REDACTED PRIVATE KEY]
  • GitHub 통합을 위한 구독(subscription)을 만들어요
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  annotations:
    notifications.argoproj.io/subscribe.<trigger-name>.github: ""

템플릿 (Templates)

template.app-deployed: |
  message: |
    Application {{.app.metadata.name}} is now running new version of deployments manifests.
  github:
    repoURLPath: "{{.app.spec.source.repoURL}}"
    revisionPath: "{{.app.status.operationState.syncResult.revision}}"
    status:
      state: success
      label: "continuous-delivery/{{.app.metadata.name}}"
      targetURL: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"
    deployment:
      state: success
      environment: production
      environmentURL: "https://{{.app.metadata.name}}.example.com"
      logURL: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"
      requiredContexts: []
      autoMerge: true
      transientEnvironment: false
      reference: v1.0.0
    pullRequestComment:
      content: |
        Application {{.app.metadata.name}} is now running new version of deployments manifests.
        See more here: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true
      commentTag: "continuous-delivery/{{.app.metadata.name}}"
    checkRun:
      name: "continuous-delivery/{{.app.metadata.name}}"
      details_url: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"
      status: completed
      conclusion: success
      started_at: "YYYY-MM-DDTHH:MM:SSZ"
      completed_at: "YYYY-MM-DDTHH:MM:SSZ"
      output:
        title: "Deployment of {{.app.metadata.name}} on ArgoCD"
        summary: "Application {{.app.metadata.name}} is now running new version of deployments manifests."
        text: |
          Application {{.app.metadata.name}} is now running new version of deployments manifests.
          See more here: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true

참고 사항:

  • 메시지가 140자 이상이면 잘려요(truncated).
  • github.repoURLPath와 github.revisionPath가 위와 같다면 생략할 수 있어요.
  • 자동 병합(automerge)은 선택 사항이며 github deployments에서 요청한 ref가 기본 브랜치와 최신 상태인지 확인하기 위해 기본값이 true예요. 기본 브랜치에서 더 오래된 ref를 배포하고 싶다면 이 옵션을 false로 설정해야 해요. 자세한 내용은 GitHub Deployment API 문서를 확인하세요.
  • github.pullRequestComment.content가 65536자 이상이면 잘려요(truncated).
  • github.pullRequestComment.commentTag 파라미터는 댓글을 식별하는 데 사용돼요. 지정한 태그가 있는 댓글이 있으면 업데이트(upsert)되고, 없으면 새 댓글이 생성돼요.
  • Reference는 선택 사항이에요. 설정하면 배포할 ref로 사용돼요. 설정하지 않으면 revision이 배포할 ref로 사용돼요.

커밋 상태 (Commit Statuses)

커밋 상태를 생성하는 방법은 동일한 커밋 SHA와 context를 사용해 최대 1000번까지 시도할 수 있어요. 이 한도에 도달하면 API가 검증 오류(HTTP 422)를 반환해요. 알림 엔진은 이러한 오류를 무시하고 알림 시도를 완료된 것으로 표시해요.

더 알아보기 (Learn more)