github.com/argoproj/argo-events@v1.9.1/docs/eventsources/setup/github.md (about)

     1  # GitHub
     2  
     3  GitHub event-source programmatically configures webhooks for projects on GitHub and helps sensor trigger the workloads on events.
     4  
     5  ## Event Structure
     6  
     7  The structure of an event dispatched by the event-source over the eventbus looks like following,
     8  
     9              {
    10                  "context": {
    11                    "type": "type_of_event_source",
    12                    "specversion": "cloud_events_version",
    13                    "source": "name_of_the_event_source",
    14                    "id": "unique_event_id",
    15                    "time": "event_time",
    16                    "datacontenttype": "type_of_data",
    17                    "subject": "name_of_the_configuration_within_event_source"
    18                  },
    19                  "data": {
    20                     "body": "Body is the Github event data",
    21                     "headers": "Headers from the Github event",
    22                  }
    23              }
    24  
    25  ## Specification
    26  
    27  GitHub event-source specification is available [here](https://github.com/argoproj/argo-events/blob/master/api/event-source.md#githubeventsource). <br />
    28  Example event-source yaml file is [here](https://github.com/argoproj/argo-events/blob/master/examples/event-sources/github.yaml).
    29  
    30  ## Setup
    31  
    32  1. Create an API token if you don't have one. Follow [instructions](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) to create a new GitHub API Token.
    33     Grant it the `repo_hook` permissions.
    34  
    35  1. Base64 encode your API token key.
    36  
    37          echo -n <api-token-key> | base64
    38  
    39  1. Create a secret called `github-access` that contains your encoded GitHub API token. You can also include a secret key that is encoded with `base64` for your webhook if any.
    40  
    41          apiVersion: v1
    42          kind: Secret
    43          metadata:
    44            name: github-access
    45          type: Opaque
    46          data:
    47            token: <base64-encoded-api-token-from-previous-step>
    48            secret: <base64-encoded-webhook-secret-key>
    49  
    50  1. Deploy the secret into K8s cluster.
    51  
    52          kubectl -n argo-events apply -f github-access.yaml
    53  
    54  1. The event-source for GitHub creates a pod and exposes it via service.
    55     The name for the service is in `<event-source-name>-eventsource-svc` format.
    56     You will need to create an Ingress or OpenShift Route for the event-source service so that it can be reached from GitHub.
    57     You can find more information on Ingress or Route online.
    58  
    59  1. Create the event source by running the following command. Make sure to replace the `url` field.
    60  
    61          kubectl apply -n argo-events -f <event-source-file-updated-in-previous-step>
    62  
    63  1. Go to `Webhooks` under your project settings on GitHub and verify the webhook is registered. You can also do the same by looking at the event-source pod logs.
    64  
    65  1. Create the sensor by running the following command.
    66  
    67          kubectl apply -n argo-events -f https://raw.githubusercontent.com/argoproj/argo-events/stable/examples/sensors/github.yaml
    68  
    69  1. Make a change to one of your project files and commit. It will trigger an argo workflow.
    70  
    71  1. Run `argo list` to find the workflow.
    72  
    73  ## Troubleshoot
    74  
    75  Please read the [FAQ](https://argoproj.github.io/argo-events/FAQ/).