GitHub
GitHub
argocd-notifications 로 GitHub 앱을 통해 commit status 를 변경하는 방법입니다. GitHub App 을 만들어 배포·PR 리뷰 상태를 알림으로 남길 수 있어요.
출처: 문서
본문
파라미터 (Parameters)
GitHub 알림 서비스는 GitHub Apps 를 사용해 commit status 를 변경하며, 다음 설정을 지정해야 합니다:
-
appID- 앱 id -
installationID- 앱 installation id -
privateKey- 앱 개인 키 -
enterpriseBaseURL- 선택 사항 URL, 예: https://git.example.com/api/v3 -
maxIdleConns- 선택 사항, 모든 호스트를 통틀어 유휴(keep-alive) 연결의 최대 수. -
maxIdleConnsPerHost- 선택 사항, 호스트당 유휴(keep-alive) 연결의 최대 수. -
maxConnsPerHost- 선택 사항, 호스트당 총 연결의 최대 수. -
idleConnTimeout- 선택 사항, 유휴(keep-alive) 연결이 닫히기 전에 유지될 최대 시간.
⚠️ NOTE: argoproj/notifications-engine#205 가 해결될 때까지 enterpriseBaseURL 에 /api/v3 를 명시해야 합니다.
설정 (Configuration)
-
https://github.com/settings/apps/new 를 사용해 GitHub App 을 만듭니다
-
리포지토리 권한을 변경해 commit status 및/또는 deployments 및/또는 pull requests comments 쓰기를 활성화합니다
-
개인 키(private key)를 생성하고 자동으로 다운로드합니다
-
계정에 앱을 설치합니다
-
argocd-notifications-secretSecret 에 privateKey 를 저장하고,argocd-notifications-cmConfigMap 에 GitHub 통합을 구성합니다
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
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
참고 사항:
-
message 가 140자 이상이면 잘립니다(truncated).
-
github.repoURLPath와github.revisionPath가 위와 같다면 생략할 수 있어요. -
Automerge 는 선택 사항이며, 요청한 ref 가 기본 브랜치와 최신 상태로 유지되도록 github deployment 에서 기본적으로
true입니다. 기본 브랜치에서 더 오래된 ref를 배포하려면 이 옵션을false로 설정해야 해요. 자세한 내용은 GitHub Deployment API Docs 를 참고하세요. -
github.pullRequestComment.content가 65536자 이상이면 잘립니다. -
github.pullRequestComment.commentTag파라미터는 댓글을 식별하는 데 쓰입니다. 지정된 태그의 댓글이 있으면 갱신(upsert)되고, 없으면 새 댓글이 생성됩니다. -
Reference 는 선택 사항입니다. 설정하면 배포할 ref 로 사용됩니다. 설정하지 않으면 revision 이 배포할 ref 로 사용돼요.
Commit Statuses
commit status 생성 방법은 같은 commit SHA 와 context 를 사용해 최대 1000회의 시도를 허용합니다. 이 한도에 도달하면 API 가 검증 오류(HTTP 422)를 반환합니다. 알림 엔진은 이 오류를 무시하고 알림 시도를 완료된 것으로 표시합니다.