* It's fairly simple to set this script up on your server/Uberspace, here's how:
*
* 1. Setup the toolkit, so you can access the tools from your SSH shell (more about that in README.md)
* 2. Take a look at the settings above.
* 2.1. Seriously, have you set a secret? Yes? Alright.
* 3. Place this script in a directory in ~/web/ (something like "~/web/hooks.example.com")
* 4. You should now be able to access https://hooks.example.com/webhook.gitea.php
* This should output "Web hook event (X-Gitea-Event header) is missing from request.".
*
* Now you can create projects and let this script deploy them for you:
*
* 5. If your project is a private repository:
* 5.1. Generate an SSH key by using `ssh-keygen`. The default values are alright for this purpose.
* 5.2. Copy the contents of `~/.ssh/id_rsa.pub` to your clipboard and add it as "Deploy Key" in your project's Gitea settings interface.
* 6. Create the project on the server by running either `project_add <path> <exact HTTPS clone url from Gitea>#<branch to deploy>` or
* `site_add <name> <exact HTTPS clone url from Gitea>#<branch to deploy>`.
* It's important to use the exact HTTPS url (not the SSH one) so this script can find the project!
* 7. Add the URL (the one you tested in 4.) of the script to your project's web hooks (choose the type "Gitea").
* Make sure to add the secret configured above and select the "POST" method, the "application/json" type and the "Push Events" trigger.
* 8. To test if it everything works, push some code to your Gitea repository.
*
* Troubleshooting:
* - Use `tail -f <path to project>/logs/*.log`. This should tell you what went wrong.
* - Check if the TOOLKIT_PATH you set above is correct.
* - Check if you set the origin of your project to the correct URL.
* - Open the web hook URL you entered in Gitea in your browser and check if the output is "Web hook event (X-Gitea-Event header) is missing from request.".
* - Click on the pen icon next to your web hook in Gitea's settings interface. You should see a list of "recent deliveries".
* You can find the exact error message from this script in the "Response" tab of the delivery.
*/
// 3. Done
// The code starts here
// ====================
// We are always returning plain text
header('Content-Type: text/plain');
// Check if a secret has been set
if (SECRET === '{{ '{{' }} projectr_deploy_secret }}') {
http_response_code(500);
die('No secret has been set in ' . basename(__FILE__) . ". This script won't work without one.");
}
// Check which event this is
if (isset($_SERVER['HTTP_X_GITEA_EVENT']) !== true) {
http_response_code(400);
die('Web hook event (X-Gitea-Event header) is missing from request.');