# 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"}
```
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-Action: "/test"
```
### Actions
TBD:
* `/label ` - add a label `` to the pull request
* `/test` - run tests pipeline (requires `test` label)
* `/deploy` - deploy pull request in preview environment (requires `deploy` label)
Response Headers:
```
Issue:
Commit:
```
# Build and run
Create git authentication secret:
```
cat <secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: git-auth
namespace: webhook-interceptor
type: Opaque
stringData:
github.com: ":"
EOF
```
```
echo KO_DOCKER_REPO='gcr.io/my-gcloud-project-name' >env.txt
./build.sh
```