argoproj / notifications-engine

Affordable notifications for Kubernetes
Apache License 2.0
271 stars 147 forks source link

Allow GitHub InstallationID override #324

Open dlactin opened 2 months ago

dlactin commented 2 months ago

This likely needs more work, but I wanted some input before digging deeper into it.

Right now, we can use a single GitHub App Installation for these notifications; if you have other GitHub organizations which have a unique installation ID, you cannot use the GitHub service for all of them.

There are a couple of existing solutions here:

I am proposing a reasonably simple change that would allow the Installation ID to be passed into the template to override the default Installation ID. This would require the installation ID to be attached to an ArgoCD application as info metadata or custom templates for each GitHub organization.

This will still use a single GitHub App, but it could be installed in multiple GitHub organizations.

ex:

template.app-deployed-github-orgname: |
  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}}"
    installationID: "1234567"
    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