# webhook-interceptor The Webhook Interceptor checks for specific conditions when a webhook is received. This way we can trigger cleanups when the PR is closed. # HTTP Headers ## Push Event ``` X-Interceptor-Push-Ref: string: "refs/heads/master" X-Interceptor-Include-Repo: []string{"my/repo"} X-Interceptor-Exclude-Repo: []string{"my/repo"} ``` Response Headers: ``` Commit: ``` ## Pull-Request Event ``` X-Interceptor-Pr-Action: []string{"opened", "reopened", "synchronize", "synchronized"} ``` Response Headers: ``` Issue: Commit: ``` ## Issue Comment Event ``` X-Interceptor-Comment: "/test-deploy" X-Interceptor-Comment-Action: []string{"created"} X-Interceptor-Label: "test-deploy:#aabbcc" X-Interceptor-Remove-Labels: []string{"test", "deploy"} ``` ### Actions * `/test` - add `test` label and run test pipeline * `/deploy` - add `deploy` label and run deploy pipeline * `/test-deploy` - add `test-deploy` label and run test-deploy pipeline Response Headers: ``` Issue: Commit: ``` ## Validate Webhooks Add secret webhook keys you want to have validated. **NOTE:** the name must be `webhook-secret`. ``` cat <webhook-secret.yaml apiVersion: v1 kind: Secret metadata: name: webhook-secret namespace: webhook-interceptor type: Opaque stringData: github.com: "" github.com_foo: "" github.com_foo_bar: "" EOF ``` # Build and run Create git authentication secret: **NOTE:** the name must be `git-auth`. ``` cat <secret.yaml apiVersion: v1 kind: Secret metadata: name: git-auth namespace: webhook-interceptor type: Opaque stringData: github.com: ":" github.com_foo: ":" github.com_foo_bar: ":" EOF ``` ``` echo KO_DOCKER_REPO='gcr.io/my-gcloud-project-name' >env.txt ./build.sh ```