-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebhook-trigger.Rmd
More file actions
58 lines (53 loc) · 1.11 KB
/
webhook-trigger.Rmd
File metadata and controls
58 lines (53 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
title: "webhook-trigger"
author: "Cole Arendt"
date: "1/29/2020"
output: html_document
params:
url:
input: text
label: Webhook URL
value: "http://ipecho.net/plain"
name:
input: text
label: Description of Task
value: "Echo my IP Address"
github:
input: checkbox
label: Is this a GitHub Webhook?
value: false
json:
input: text
label: JSON data to use as the payload
value: "{}"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(httr)
```
# `r params$text`
Calling `r params$url`
```{r tag_url}
if (params$github) {
message("Running a GitHub webhook")
if (Sys.getenv("GITHUB_PAT") == "") {
stop("GITHUB_PAT environment variable is required")
}
res <- httr::POST(
url = params$url,
body = params$json,
httr::add_headers(
Accept = "application/vnd.github.v3+json",
Authorization = glue::glue("Bearer {Sys.getenv('GITHUB_PAT')}")
)
)
} else {
message("Running a NON-GitHub webhook")
res <- httr::POST(
url = params$url,
body = params$json,
)
}
httr::content(res)
httr::http_status(res)
```