List Deployments

@link https://developer.github.com/v3/repos/deployments/#list-deployments

@param string $sha
@param string $ref
@param string $task
@param string $environment

@return array
489751
public function listDeployments(string $sha = null, string $ref = null, string $task = null,
                                    string $environment = null): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/deployments',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(),
            http_build_query(['sha' => $sha, 'ref' => $ref, 'task' => $task, 'environment' => $environment])));
    }
1049826
public static function action($task)
    {
        //====================================================================//
        // Stack Trace
        Splash::log()->trace();
        Splash::log()->deb("Object => ".$task->name." (".$task->desc.")");

        //====================================================================//
        //  READING OF SERVER OBJECT LIST
        //====================================================================//
        if (SPL_F_OBJECTS === $task->name) {
            return self::doObjects($task);
        }

        //====================================================================//
        // Safety Check - Minimal Parameters
        //====================================================================//
        // Verify Requested Object Type is Available
        if (!self::isValidTask($task)) {
            return self::getEmptyResponse($task);
        }

        //====================================================================//
        // Execute Admin Actions
        //====================================================================//
        if (in_array($task->name, array( SPL_F_DESC , SPL_F_FIELDS , SPL_F_LIST ), true)) {
            return self::doAdminActions($task);
        }
        if (in_array($task->name, array( SPL_F_GET , SPL_F_SET , SPL_F_DEL ), true)) {
            return self::doSyncActions($task);
        }
        if (in_array($task->name, array( SPL_F_COMMIT ), true)) {
            Splash::log()->war("Objects - Requested task not found => ".$task->name);

            return self::getEmptyResponse($task);
        }
        //====================================================================//
        // Task Not Found
        Splash::log()->err("Objects - Requested task not found => ".$task->name);

        return self::checkResponse(self::getEmptyResponse($task));
    }
235011
protected function listFilesToRename($remote_host, $remote_dir)
	{
		if (!isset($this->files_to_rename["$remote_host-$remote_dir"]))
		{
			$target_files_to_move = array();

			// doelspecifieke files hernoemen
			if (!empty($this->target_specific_files))
			{
				foreach ($this->target_specific_files as $filepath)
				{
					$ext = pathinfo($filepath, PATHINFO_EXTENSION);

					if (isset($target_files_to_move[$filepath]))
					{
						$target_filepath = str_replace(".$ext", ".{$this->target}.$ext", $target_files_to_move[$filepath]);
					}
					else
					{
						$target_filepath = str_replace(".$ext", ".{$this->target}.$ext", $filepath);
					}

					$target_files_to_move[$filepath] = $target_filepath;
				}
			}

			// controleren of alle files bestaan
			if (!empty($target_files_to_move))
			{
				foreach ($target_files_to_move as $current_filepath)
				{
					if (!file_exists($current_filepath))
					{
						throw new DeployException("$current_filepath does not exist");
					}
				}
			}

			$this->files_to_rename["$remote_host-$remote_dir"] = $target_files_to_move;
		}

		return $this->files_to_rename["$remote_host-$remote_dir"];
	}
824858
public static function co(array $tasks): array
    {
        $taskCos = [];
        foreach ($tasks as $task) {
            if (! isset($task['type']) || ! isset($task['name']) || ! isset($task['method']) || ! isset($task['params'])) {
                App::error(sprintf('Task %s format error.', $task['name'] ?? '[UNKNOWN]'));
                continue;
            }

            $type = $task['type'];
            if ($type !== static::TYPE_CO) {
                App::error(sprintf('Task %s is not a coroutine task.', $task['name']));
                continue;
            }

            $taskCos[] = TaskHelper::pack($task['name'], $task['method'], $task['params'], $task['type']);
        }

        $result = [];
        if (! empty($taskCos)) {
            $result = App::$server->getServer()->taskCo($tasks);
        }

        return $result;
    }
686697
public function getSingleCommit($owner, $repo, $sha)
	{
		$data = array();
		
		return $this->client->request("/repos/$owner/$repo/commits/$sha", 'GET', $data, 200, 'GitHubFullCommit', true);
	}
1031577
def file_list(ref)
      if (sha = @access.ref_to_sha(ref))
        commit = @access.commit(sha)
        tree_map_for(sha).inject([]) do |list, entry|
          next list if entry.name.start_with?('_')
          next list if @page_class.valid_page_name?(entry.name)
          list << entry.file(self, commit)
        end
      else
        []
      end
    end
372063
def environment_list_command(environment_command)
      environment_command.desc 'List the remote environments in the project'
      environment_command.command :list do |environment_list_command|
        environment_list_command.action do |global_options,options,args|
          environments = Bebox::Environment.list(project_root)
          title _('cli.environment.list.current_envs')
          environments.map{|environment| msg(environment)}
          warn(_('cli.environment.list.no_envs')) if environments.empty?
        end
      end
    end
178398
protected function listProperties(Environment $environment)
    {
        $headings = [];
        $values = [];
        foreach ($environment->getProperties() as $key => $value) {
            $headings[] = new AdaptiveTableCell($key, ['wrap' => false]);
            $values[] = $this->formatter->format($value, $key);
        }
        /** @var \Platformsh\Cli\Service\Table $table */
        $table = $this->getService('table');
        $table->renderSimple($values, $headings);

        return 0;
    }
864511
public function getPropertiesForEnvironment(Application $application, ?Environment $environment): array
    {
        $environmentCriteria = Criteria::expr()->isNull('environment');

        if ($environment) {
            $specificEnvironment = Criteria::expr()->eq('environment', $environment);
            $environmentCriteria = Criteria::expr()->orX($specificEnvironment, $environmentCriteria);
        }

        $criteria = (new Criteria)
            ->where(Criteria::expr()->eq('application', $application))
            ->andWhere($environmentCriteria)

            // null must be first!
            ->orderBy(['environment' => 'ASC']);

        $properties = $this
            ->matching($criteria)
            ->toArray();


        $config = [];

        // We do this so that "global/no-env" properties are loaded first, and can be overwritten by environment-specific config.
        foreach ($properties as $property) {
            $config[$property->name()] = $property;
        }

        return $config;
    }
780940
public function refreshExpiredCache($environment = null, $forceRefresh = false)
    {
        $hasBeenRefreshed = false;
        foreach ($this->cacheManagers as $cacheManager) {
            $hasBeenRefreshed =  $cacheManager->refreshExpiredCache($environment, $forceRefresh) || $hasBeenRefreshed;
        }
        return $hasBeenRefreshed;
    }
158752
def list_tasks(collector):
    """"""
    print("Usage: aws_syncr <environment> <task>")
    print("")
    print("Available environments to choose from are")
    print("-----------------------------------------")
    print("")
    for environment in os.listdir(collector.configuration_folder):
        location = os.path.join(collector.configuration_folder, environment)
        if os.path.isdir(location) and not environment.startswith("."):
            print("\t{0}".format(environment))

    print("")
    print("Available tasks to choose from are:")
    print("-----------------------------------")
    print("")
    keygetter = lambda item: item[1].label
    tasks = sorted(available_actions.items(), key=keygetter)
    sorted_tasks = sorted(list(tasks), key=lambda item: len(item[0]))
    max_length = max(len(name) for name, _ in sorted_tasks)
    for key, task in sorted_tasks:
        desc = dedent(task.__doc__ or "").strip().split('\n')[0]
        print("\t{0}{1} :-: {2}".format(" " * (max_length-len(key)), key, desc))
    print("")
204853
public function load($environment = null)
    {
        foreach ($this->loader->load($environment) as $key => $value) {
            $_ENV[$key] = $value;

            $_SERVER[$key] = $value;

            putenv("{$key}={$value}");
        }
    }
66829
protected function fetchSources(Task $task)
    {
        $sources = [];

        foreach ($task->getSources() as $source) {
            // locate new resource and merge them to the existing sources
            $sources = array_merge($sources, $this->locator->locate($source));
        }

        return $sources;
    }
747346
public function listCommand($hostname = null)
    {
        if ($hostname === null) {
            $domains = $this->domainRepository->findAll();
        } else {
            $domains = $this->domainRepository->findByHostname($hostname);
        }

        if (count($domains) === 0) {
            $this->outputLine('No domain entries available.');
            $this->quit(0);
        }

        $availableDomains = [];
        foreach ($domains as $domain) {
            /** @var \Neos\Neos\Domain\Model\Domain $domain */
            $availableDomains[] = [
                'nodeName' => $domain->getSite()->getNodeName(),
                'hostname' => (string)$domain,
                'active' => $domain->getActive() ? 'active' : 'inactive'
            ];
        }

        $this->output->outputTable($availableDomains, ['Node name', 'Domain (Scheme/Host/Port)', 'State']);
    }
386844
public function generatePackage($sha, $baseDir, $outputFilename, DeploynautLogFile $log) {
		$tempPath = TEMP_FOLDER . "/" . str_replace(".tar.gz", "", basename($outputFilename));
		if(!file_exists($tempPath)) mkdir($tempPath);

		// Execute these in sequence until there's a failure
		$processes = array(
			// Export the relevant SHA into a temp folder
			new Process("git archive $sha | tar -x -C " . escapeshellarg($tempPath), $baseDir),
			// Run build script
			new Process($this->buildScript, $tempPath, null, null, 3600),
			// Compress the result
			new Process("tar -czf " . escapeshellarg($outputFilename) . " " . escapeshellarg(basename($tempPath)), dirname($tempPath)),
		);

		// Call at the end, regardless of success or failure
		$cleanup = array(
			// Delete the temporary staging folder
			new Process("rm -rf " . escapeshellarg($tempPath)),
		);

		try {
			$this->executeProcesses($processes, $log);
		} catch(Exception $e) {
			// Execute cleanup on failure
			$this->executeProcesses($cleanup, $log);
			throw $e;
		}

		// Execute cleanup on success
		$this->executeProcesses($cleanup, $log);
		return true;
	}
693036
public function listAll($ref = null)
    {
        if (is_null($ref)) {
            $ref = 'HEAD';
        }
        $this->clearAll();

        $this->addCommandName(self::LS_TREE_COMMAND);
        $this->addCommandSubject($ref);

        return $this->getCommand();
    }
1210356
protected function buildCommitSelector($project, $pipelineCommits = null) {
		// Branches
		$branches = array();
		foreach($project->DNBranchList() as $branch) {
			$sha = $branch->SHA();
			$name = $branch->Name();
			$branches[$sha . '-' . $name] = $name . ' (' . substr($sha,0,8) . ', ' . $branch->LastUpdated()->TimeDiff() . ' old)';
		}

		// Tags
		$tags = array();
		foreach($project->DNTagList()->setLimit(null) as $tag) {
			$sha = $tag->SHA();
			$name = $tag->Name();
			$tags[$sha . '-' . $name] = $name . ' (' . substr($sha,0,8) . ', ' . $tag->Created()->TimeDiff() . ' old)';
		}
		$tags = array_reverse($tags);

		// Past deployments
		$redeploy = array();
		foreach($project->DNEnvironmentList() as $dnEnvironment) {
			$envName = $dnEnvironment->Name;
			foreach($dnEnvironment->DeployHistory() as $deploy) {
				$sha = $deploy->SHA;
				if(!isset($redeploy[$envName])) {
					$redeploy[$envName] = array();
				}
				if(!isset($redeploy[$envName][$sha])) {
					$redeploy[$envName][$sha] = substr($sha,0,8) . ' (deployed ' . $deploy->obj('LastEdited')->Ago() . ')';
				}
			}
		}

		// Merge fields
		$releaseMethods = array();
		if($pipelineCommits) {
			$releaseMethods[] = new SelectionGroup_Item(
				'FilteredCommits',
				$this->buildPipelineField($pipelineCommits),
				'Deploy a commit prepared for this pipeline'
			);
		}
		if($branches) {
			$releaseMethods[] = new SelectionGroup_Item(
				'Branch',
				new DropdownField('Branch', '', $branches),
				'Deploy the latest version of a branch'
			);
		}
		if($tags) {
			$releaseMethods[] = new SelectionGroup_Item(
				'Tag',
				new DropdownField('Tag', '', $tags),
				'Deploy a tagged release'
			);
		}
		if($redeploy) {
			$releaseMethods[] = new SelectionGroup_Item(
				'Redeploy',
				new GroupedDropdownField('Redeploy', '', $redeploy),
				'Redeploy a release that was previously deployed (to any environment)'
			);
		}

		$releaseMethods[] = new SelectionGroup_Item(
			'SHA',
			new Textfield('SHA', 'Please specify the full SHA'),
			'Deploy a specific SHA'
		);

		$field = new SelectionGroup('SelectRelease', $releaseMethods);
		$field->setValue(reset($releaseMethods)->getValue());
		$field->addExtraClass('clearfix');
		return $field;
	}