GithubHelp home page GithubHelp logo

lancepioch / tree Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 3.0 2.14 MB

Connect your Github Repository to your Forge Server and Tree automatically deploys any new pull requests for you

License: MIT License

PHP 80.28% Vue 0.30% Blade 19.05% JavaScript 0.15% SCSS 0.22%
deploy github laravel php pull-requests

tree's Introduction

Hi there, I'm Lance ๐Ÿ‘‹

I am the Project Maintainer of Pelican.

๐Ÿ’ฌ Ask me about Livewire or Pelican if you have any technical questions ๐Ÿ‘
โšก Fun fact, I've got 5 years of martial arts experience ๐Ÿฅ‹
๐Ÿ“ซ Feel free to email me about anything business related, here: me@[my first name].sh ๐Ÿ“ง

tree's People

Contributors

alouini333 avatar dependabot[bot] avatar lancepioch avatar stylecibot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tree's Issues

Replace sleeps with new jobs

while ($site->status !== 'installed') {
sleep(5);
$site = $forge->site($project->forge_server_id, $site->id);
}

while ($site->repositoryStatus !== 'installed') {
sleep(5);
$site = $forge->site($project->forge_server_id, $site->id);
}
sleep(10);

while ($site->deploymentStatus !== null) {
sleep(5);
$site = $forge->site($project->forge_server_id, $site->id);
}

Use release method along with $tries.

Remove references to global namespaced facades

For example, you're referencing \DB or importing use DB. Instead import Illuminate\Support\Facades\DB and reference DB.

While global references are allowed through aliases, you should import the facade explicitly. This can improve clarity not only for developers, but static analysis used by your IDE.

Add Tests

The api calls themselves are impossible to directly test, so they have to be mocked along with making sure the jobs eventually call the right commands.

Leverage custom tree or forest config files instead of changing the defaults

You should leverage ENV variables rather than hardcode values. If you find you're adding a lot of configuration options, consider creating a domain specific config file, such as core.php. Both will make app upgrades and deployments easier.

  • config/app.php
  • config/filesystems.php
  • config/queue.php
  • config/services.php

Update Github Api Dependency

On February 11th your application (Laravel Forest) used an access token (with the User-Agent GuzzleHttp/6.5.1 curl/7.64.0 PHP/7.3.5) as part of a query parameter to access an endpoint through the GitHub API: https://api.github.com/user

Please use the Authorization HTTP header instead as using the access_token query parameter is deprecated and will be removed July 1st, 2020.

Visit https://developer.github.com/changes/2019-11-05-deprecated-passwords-and-authorizations-api/#authenticating-using-query-parameters for more information.

Thanks,
The GitHub Team

Utilize Form Requests

https://laravel.com/docs/5.6/validation#creating-form-requests

$input = $request->input();
$signature = $request->header('X-Hub-Signature');
$event = $request->header('X-GitHub-Event');
if ($event === 'ping') {
return response()->json('ping');
}
abort_unless(isset($input['pull_request']), 400, 'Not a Pull Request');
abort_unless(isset($input['repository']), 400, 'Not a Repository');
abort_if(is_null($signature) || !str_contains($signature, '='), 400, 'Signature Required');
[$algorithm, $signature] = explode('=', $signature, 2);
$pullRequest = $input['pull_request'];
$project = Project::where('github_repo', $input['repository']['full_name'])->with(['branches', 'user'])->first();
abort_if($project === null, 400, 'Project Not Found');
$branch = $project->branches()->where('issue_number', $pullRequest['number'])->orderBy('id', 'desc')->first();
// Signature Verification
$hash = hash_hmac($algorithm, $request->getContent(), $project->webhook_secret);
abort_unless(
$hash === $signature,
400,
response()->json([
'error' => 'Signature Verification Failed',
'hash' => $hash,
'signature' => $signature,
])
);

Respond positively to the initial webhook ping

Headers:

Request URL: https://example.com/api/webhooks/github/pullrequest
Request method: POST
content-type: application/json
Expect: 
User-Agent: GitHub-Hookshot/419cd30
X-GitHub-Delivery: cfa01320-5efd-11e8-967a-7c425233ad3b
X-GitHub-Event: ping
X-Hub-Signature: sha1=fa1c581afa123f5b1036166c3bc3603922421850

Scheduled Cleanup

Every day or hour, run a job that checks each open pull request and ensures that there is a current site deployed for them and that any sites deployed are closed if their pull request has also been closed.

Enforce resource actions in controllers

โš  The following controllers contain actions outside of the 7 resource actions (index, create, store, show, edit, update, destroy). For more details, review the docs or watch Cruddy by Design to see if you can rework these into resource controllers.

  • app/Http/Controllers/Auth/LoginController.php
  • app/Http/Controllers/HomeController.php
  • app/Http/Controllers/WebhookController.php

Native Environment Variable Injection

Instead of this in the deployment:

sed -i -E 's/GITHUB_CLIENT_ID=.+/GITHUB_CLIENT_ID=abc123def4567890abcd/' .env

It'd be nice to have a way to just set env variables for each project.

Make the github name optional

If the user's Github name isn't set, then the app throws an error because it depends on that. Instead use the user's email address as a backup for their name.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.