Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic GitHub event source #1174

Merged
merged 3 commits into from
Aug 10, 2023
Merged

Conversation

mszostok
Copy link
Collaborator

@mszostok mszostok commented Aug 4, 2023

Description

Changes proposed in this pull request:

  • Add basic GitHub event source

Testing

  1. Checkout PR: gh pr checkout 1174

  2. Build plugins: PLUGIN_TARGETS="flux,github-events" make build-plugins-single

  3. Start plugin server: env PLUGIN_SERVER_HOST=http://host.k3d.internal go run test/helpers/plugin_server.go

  4. Create config. Update repository name, provide github token:

    communications:
      default-group:
        socketSlack:
          enabled: true
          channels:
            default:
              name: random
              bindings:
                sources:
                  - github-events
                executors:
                  - flux
          appToken: "xapp-"
          botToken: "xoxb-"
    
    sources:
    
      github-events:
        displayName: "GitHub Events"
        botkube/github-events:
          enabled: true
          config:
            log:
              level: debug
            github:
              auth:
                accessToken: "ghp_"
    
            repositories:
              - name: mszostok/podinfo
                on:
                  pullRequests:
                    - types: [ open ]
                      paths:
                        include: [ 'kustomize/.*' ]
                      labels:
                        include: [ 'bug' ]
                      notificationTemplate:
                        extraButtons:
                          - displayName: "Flux Diff"
                            commandTpl: "flux diff ks podinfo --path ./kustomize --github-ref {{ .HTMLURL }} "
    
              - name: mszostok/podinfo
                on:
                  events:
                    - type: "WatchEvent"
                    - type: "IssuesEvent"
                      # The JSONPath expression to filter events
                      jsonPath: ".action"
                      # The value to match in the JSONPath result
                      value: "opened"
                      notificationTemplate:
                        previewTpl: |-
                          Issue Opened
    
                          #{{ .Issue.Number }} {{ .Issue.Title }}
                          State: {{ .Issue.State }}
    
                        extraButtons:
                          - displayName: Open
                            url: "{{ .Issue.HTMLURL }}"
                            style: primary
    
              - name: kubeshop/botkube
                on:
                  events:
                    - type: "WatchEvent"
    executors:
      flux:
        botkube/flux:
          enabled: true
          config:
            log:
              level: "debug"
            github:
              auth:
                accessToken: ghp_
    
          context:
            rbac:
              group:
                type: Static
                static:
                  values: [ "system:masters" ]
    
    
    plugins:
      repositories:
        botkube:
          url: http://host.k3d.internal:3010/botkube.yaml
    
    settings:
      log:
        level: "debug"
        formatter: "text"
      clusterName: "labs"
      upgradeNotifier: false
    
    analytics:
      disable: true
    
    configWatcher:
      enabled: false
    
  5. Create a new Issue

  6. Start watched repository

  7. Create a new PR that changes specified files and has a given label

Related issue(s)

@mszostok mszostok added the enhancement New feature or request label Aug 4, 2023
@mszostok mszostok force-pushed the gh-events-source branch 2 times, most recently from 0649b39 to ab2be75 Compare August 9, 2023 19:05
@mszostok mszostok marked this pull request as ready for review August 9, 2023 19:06
@mszostok mszostok requested review from a team and huseyinbabal August 9, 2023 19:06
Copy link

@josefkarasek josefkarasek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

Just one minor comment.

return true
}

// consider using GitHub GraphQL API:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a TODO? Should it be implemented?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's more a suggestion for the future as during this task I didn't fit with GraphQL implementation but having it is just an optimization

@mszostok mszostok merged commit d7b7fe4 into kubeshop:main Aug 10, 2023
13 checks passed
@mszostok mszostok deleted the gh-events-source branch August 10, 2023 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants