Receber evento do GitHub
curl --request POST \
--url https://api.dscloud.pt/v3/git/webhook/{token} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"repository": {},
"ref": "<string>",
"after": "<string>"
}
'import requests
url = "https://api.dscloud.pt/v3/git/webhook/{token}"
payload = {
"repository": {},
"ref": "<string>",
"after": "<string>"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({repository: {}, ref: '<string>', after: '<string>'})
};
fetch('https://api.dscloud.pt/v3/git/webhook/{token}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dscloud.pt/v3/git/webhook/{token}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'repository' => [
],
'ref' => '<string>',
'after' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.dscloud.pt/v3/git/webhook/{token}"
payload := strings.NewReader("{\n \"repository\": {},\n \"ref\": \"<string>\",\n \"after\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.dscloud.pt/v3/git/webhook/{token}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"repository\": {},\n \"ref\": \"<string>\",\n \"after\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dscloud.pt/v3/git/webhook/{token}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"repository\": {},\n \"ref\": \"<string>\",\n \"after\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "accepted",
"deployment_id": "deploy_1795168800000",
"code": "SUCCESS"
}
Deploys e webhooks
Receber evento do GitHub
Configuração para entregas de eventos push do GitHub.
Receber evento do GitHub
curl --request POST \
--url https://api.dscloud.pt/v3/git/webhook/{token} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"repository": {},
"ref": "<string>",
"after": "<string>"
}
'import requests
url = "https://api.dscloud.pt/v3/git/webhook/{token}"
payload = {
"repository": {},
"ref": "<string>",
"after": "<string>"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({repository: {}, ref: '<string>', after: '<string>'})
};
fetch('https://api.dscloud.pt/v3/git/webhook/{token}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dscloud.pt/v3/git/webhook/{token}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'repository' => [
],
'ref' => '<string>',
'after' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.dscloud.pt/v3/git/webhook/{token}"
payload := strings.NewReader("{\n \"repository\": {},\n \"ref\": \"<string>\",\n \"after\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.dscloud.pt/v3/git/webhook/{token}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"repository\": {},\n \"ref\": \"<string>\",\n \"after\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dscloud.pt/v3/git/webhook/{token}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"repository\": {},\n \"ref\": \"<string>\",\n \"after\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "accepted",
"deployment_id": "deploy_1795168800000",
"code": "SUCCESS"
}
Configuração para entregas de eventos push do GitHub. Use a URL fornecida por configurar webhook. Uma aceitação indica que o deploy foi registrado. Confira o resultado no histórico.
Parâmetros
Resposta
HTTP 200 comstatus: accepted e um deployment_id para acompanhar.
{
"status": "accepted",
"deployment_id": "deploy_1795168800000",
"code": "SUCCESS"
}
Erros desta operação
| HTTP | Código | Quando ocorre |
|---|---|---|
| 404 | NOT_FOUND | Integração não encontrada. |
| 500 | INTERNAL_ERROR | O receptor não concluiu o registro do evento. |