3 namespace app\Controller\Github
;
5 use app\Controller\Github
;
6 use app\Github\API\Repos\RepoCallback
;
8 class Release
extends Github
10 function __invoke(array $args = null) {
11 if (!$this->checkToken()) {
16 $this->github
->readRepo("$owner/$name")->then(
17 new RepoCallback($this->github
)
18 )->then(function($result) use(&$repo) {
19 list($repo,,,$releases) = $result;
20 $config = $this->app
->getRequest()->getForm();
22 foreach ($releases as $release) {
23 if ($release->tag_name
=== $config["tag"]) {
24 return $this->github
->uploadAssetForRelease($repo, $release, $config);
28 return $this->github
->createReleaseFromTag($repo, $config["tag"], $config);
29 })->done(function() use(&$repo) {
30 $this->app
->redirect($this->app
->getBaseUrl()->mod(":./github/repo/" . $repo->full_name
));
33 $this->github
->drain();
35 $hook = $this->github
->checkRepoHook($repo);
36 $this->app
->getView()->addData(compact("owner", "name", "repo", "hook"));
38 if (($modal = $this->app
->getRequest()->getQuery("modal"))) {
39 $action = $this->app
->getRequest()->getQuery($modal);
40 $this->app
->getView()->addData(compact("modal", "action"));
43 $this->app
->display("github/repo");