Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add usage of bitbuckets secret token "X-Hub-Signature" #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# TS-Files
[*.ts]
indent_style = space
indent_size = 4

# TYPOSCRIPT-Files
[*.typoscript]
indent_style = space
indent_size = 4

# YAML-Files
[*.yaml]
indent_style = space
indent_size = 2

# CSS-Files
[*.css]
indent_style = space
indent_size = 4

# HTML-Files
[*.html]
indent_style = space
indent_size = 4

# TMPL-Files
[*.tmpl]
indent_style = space
indent_size = 4

# LESS-Files
[*.less]
indent_style = space
indent_size = 4

# SASS-Files
[*.sass]
indent_style = space
indent_size = 4

# SCSS-Files
[*.scss]
indent_style = space
indent_size = 4

# JS-Files
[*.js]
indent_style = space
indent_size = 4

# PHP-Files
[*.php]
indent_style = space
indent_size = 4

# MD-Files
[*.md]
indent_style = space
indent_size = 4

# XLF-Files
[*.xlf]
indent_style = space
indent_size = 4

# JSON-Files
[*.json]
indent_style = space
indent_size = 4

# YML-Files
[*.yml]
indent_style = space
indent_size = 2

# SQL-Files
[*.sql]
indent_style = space
indent_size = 4

# package.json
[package.json, package-lock.json]
indent_style = space
indent_size = 2
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Use the following steps to set up a new gitwebhook on your github (or bitbucket)

1. Go to your Repository and click on "Settings", then click on "Webhooks"
2. Click on "Add webhook"
3. Type in the path where you want to install your gitwebhook: https://\<example.com\>/gitwebhook/index.php?bitbucket_secret=\<secret\> (or as subdomain, etc.)

(replace \<secret\> with a Secret of your choice)
3. Type in the name of the webhook (your own custom name) in the field "Title"
4. Type in the path where you want to install your gitwebhook (field "URL"): https://\<example.com\>/gitwebhook/index.php (or as subdomain, etc.)
5. Add your \<secret\> in the "secret" field (replace \<secret\> with a Secret of your choice)

### Setup Gitwebhook (Second Step):

Expand All @@ -32,7 +32,7 @@ Use the following steps to set up a new gitwebhook on your github (or bitbucket)
2. Clone the gitwebhook

```
git clone https://github.com/iocron/gitwebhook.git && cd gitwebhook
git clone https://github.com/Teisi/gitwebhook.git && cd gitwebhook
```

3. Copy configuration file and htaccess so you can use them:
Expand Down
62 changes: 31 additions & 31 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<?php
// Requirements / Includes
require_once(__DIR__."/lib/gitwebhook.php");

// Config / Default Settings
$configFile = __DIR__."/configs/config.json";
if(file_exists($configFile)){
$config = json_decode(file_get_contents($configFile),true);

if(!is_readable($configFile)){
$errMsg = "[ERROR]: The Gitwebhook Config File ({$configFile}) is not accessible / readable.";
if(ini_get('display_errors') != "1") echo "{$errMsg}";
throw new Exception("{$errMsg}");
}
if(empty($config) || !is_array($config)){
$errMsg = "[ERROR]: The Gitwebhook Config File ({$configFile}) is not a valid JSON File.";
if(ini_get('display_errors') != "1") echo "{$errMsg}";
throw new Exception("{$errMsg}");
}
} else {
$errMsg = "[ERROR]: The Gitwebhook Config File ({$configFile}) doesn't exist (or the path is not accessible)!";
if(ini_get('display_errors') != "1") echo "{$errMsg}";
// Requirements / Includes
require_once(__DIR__."/lib/gitwebhook.php");

// Config / Default Settings
$configFile = __DIR__."/configs/config.json";

if(!file_exists($configFile)) {
$errMsg = "[ERROR]: The Gitwebhook Config File ({$configFile}) doesn't exist (or the path is not accessible)!";
if(ini_get('display_errors') != "1") echo "{$errMsg}";
throw new Exception("{$errMsg}");
}

// Gitwebhook
$webhook = new Gitwebhook($config);
$webhookData = $webhook->getData();
$validate = $webhook->validateInit();

if($validate){
}

$config = json_decode(file_get_contents($configFile),true);

if(!is_readable($configFile)) {
$errMsg = "[ERROR]: The Gitwebhook Config File ({$configFile}) is not accessible / readable.";
if(ini_get('display_errors') != "1") echo "{$errMsg}";
throw new Exception("{$errMsg}");
}

if(empty($config) || !is_array($config)) {
$errMsg = "[ERROR]: The Gitwebhook Config File ({$configFile}) is not a valid JSON File.";
if(ini_get('display_errors') != "1") echo "{$errMsg}";
throw new Exception("{$errMsg}");
}

// Gitwebhook
$webhook = new Gitwebhook($config);
$validate = $webhook->validateInit();

if($validate) {
$webhook->handle();
}
?>
}
Loading