consolidation / robo

Modern task runner for PHP
http://robo.li
Other
2.67k stars 304 forks source link

How do I update Robo version in a repository #1099

Closed judy-akers closed 2 years ago

judy-akers commented 2 years ago

Steps to reproduce

I have been told to take over the assignment/project of using Robo to update our Drupal 7 github/Acquia websites because the previous person left the agency. Currently the project using Robo 1.4.14-dev version, and our repository code was written over 3 years ago. Our documentation is minimal on our RoboFile.php

Expected behavior

The 'POST https://api.github.com/repos/ny//pulls' command was username and password for API calls, and it is no longer able to authenticate using this now. https://docs.github.com/en/rest/overview/troubleshooting#basic-authentication-errors

I have reviewed our RoboFile.php and cannot find the POST command in it. So I am lead to believe it must exist elsewhere.

Because it is asking for an Authorization Header, and I think I need to update Robo version inside of the project repository -OR- be given instructions on how to override the userid/password accessToken and use an Authorization Header.

Actual behavior

Error that is returned when using 'robo git:create-github-pr --sites=""

[App\WebNY\GitHub\GitHubPR] Creating PR [App\WebNY\GitHub\GitHubPR] https://api.github.com/repos/ny//pulls [App\WebNY\GitHub\GitHubPR] POST https://api.github.com/repos/ny//pulls [App\WebNY\GitHub\GitHubPR] {"message":"Must specify access token via Authorization header. https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param","documentation_url":"https://docs.github.com/v3/#oauth2-token-sent-in-a-header"} [App\WebNY\GitHub\GitHubPR] Must specify access token via Authorization header. https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param Time 0.38s [App\WebNY\GitHub\GitHubPR] Exit code 1 Time 0.38s ➜ Ugh, we failed.

System Configuration

Which O.S. and PHP version are you using? Using a MacBook Pro (MacOS Big Sur version 11.6.2) and PHP 7.4

judy-akers commented 2 years ago

The code from our robofile.php for a pull request:

public function gitCreateGithubPR($opts = ['sites|s' => '', 'accessToken|a' => '', 'title|t' => '', 'head' => '', 'base' => '', 'description|d' => '']) { $results = [];

$sites = $this->sitesFromOpts($opts['sites']);

if (isset($_SERVER['WEBNYPLATFORM_ACCESS_TOKEN'])) {
  $accessToken = $_SERVER['WEBNYPLATFORM_ACCESS_TOKEN'];
}else {
  $accessToken = ($opts['accessToken'] == '') ?
    str_replace(["\n", "\r"], "", $this->ask(ACCESS_TOKEN_MSG)) :
    $opts['accessToken'];
}

foreach ($sites as $site) {
  $githubUserRepo = $this->githubUserRepoFromGitAddress($site->git->github);
  try {
    $results[] = $this->taskGitHubPR($opts['title'], $opts['head'], $opts['base'], $opts['description'])
      ->uri($githubUserRepo)
      ->accessToken($accessToken)
      ->run();
  }catch(Exception $e) {
    printf("Unable to create the PR: %s", $e->getMessage());
  }
}

$this->checkSuccess($results);

}

greg-1-anderson commented 2 years ago

Duplicate of #1098