releaseaction.class.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace DebenOldert\AutoDeploy;
  3. include 'action.class.php';
  4. class ReleaseAction extends Action
  5. {
  6. public function shouldDownload() : bool
  7. {
  8. return (!$this->json->release->draft
  9. && !$this->json->release->prerelease)
  10. || ($this->settings['acceptDraft']
  11. && $this->json->release->draft)
  12. || ($this->settings['acceptPre']
  13. && $this->json->release->prerelease);
  14. }
  15. public function formatDownloadName() : string
  16. {
  17. return "{$this->settings['download_dir']}/{$this->json->repository->name}-{$this->json->release->tag_name}.zip";
  18. }
  19. public function formatUnZipName() : string
  20. {
  21. return "{$this->settings['download_dir']}/{$this->json->repository->name}-{$this->json->release->tag_name}";
  22. }
  23. public function formatUrl() : string
  24. {
  25. $parsed = parse_url($this->json->repository->html_url);
  26. $domain = "{$parsed['scheme']}://{$parsed['host']}";
  27. return "{$domain}/api/v1/repos/{$this->json->repository->owner->username}/{$this->json->repository->name}/archive/{$this->json->release->tag_name}.zip?token={$this->key}";
  28. }
  29. public function formatRealName() : string
  30. {
  31. return include_once "{$this->unzipName}/base.class.php";
  32. }
  33. }