Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Commands/GitPull.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$remote = Git::remoteName( $repo_dir );

// First, run a fetch to update all origin/<branch> refs to latest:
$response = Shell::run("git -C '$repo_dir' fetch $remote", $return_var);
$response = Shell::run("GIT_TERMINAL_PROMPT=0 git -C '$repo_dir' fetch $remote", $return_var);
if ($response) $output->writeln($response);

// if the fetch failed, then stop
Expand Down
30 changes: 30 additions & 0 deletions src/Commands/ProtocolStart.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
use Gitcd\Helpers\Crontab;
use Gitcd\Helpers\Secrets;
use Gitcd\Helpers\StageRunner;
use Gitcd\Helpers\GitHubApp;
use Gitcd\Helpers\SecurityAudit;
use Gitcd\Helpers\Soc2Check;
use Gitcd\Helpers\BlueGreen;
Expand Down Expand Up @@ -160,9 +161,38 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// ── Stage 2: Infrastructure provisioning ────────────────
$runner->run('Infrastructure provisioning', function() use ($runner, $app, $arrInput, $arrInput1, $nullOutput, $repo_dir, $environment, $strategy, $isDev, $nodeConfig, $nodeData) {

// Refresh GitHub App credentials and fix remote URLs if needed
if (GitHubApp::isConfigured()) {
$creds = GitHubApp::loadCredentials();
$appOwner = $creds['owner'] ?? null;
if ($appOwner) {
$runner->log("Refreshing GitHub App credentials for {$appOwner}");
GitHubApp::refreshGitCredentials($appOwner);
}

// Update git remote URL in cloned repos to use HTTPS
$currentRemote = trim(Shell::run("git -C " . escapeshellarg($repo_dir) . " remote get-url origin 2>/dev/null") ?: '');
$resolvedRemote = GitHubApp::resolveUrl($currentRemote);
if ($currentRemote && $resolvedRemote !== $currentRemote) {
$runner->log("Updating remote URL: {$currentRemote} β†’ {$resolvedRemote}");
Shell::run("git -C " . escapeshellarg($repo_dir) . " remote set-url origin " . escapeshellarg($resolvedRemote) . " 2>/dev/null");
}
}

$configRemote = Json::read('configuration.remote', false, $repo_dir);
$configRepo = Config::repo($repo_dir);
$hasConfigRepo = $configRemote || is_dir($configRepo);

// Also fix config repo remote URL if it was cloned with SSH
if (GitHubApp::isConfigured() && is_dir($configRepo)) {
$configCurrentRemote = trim(Shell::run("git -C " . escapeshellarg($configRepo) . " remote get-url origin 2>/dev/null") ?: '');
$configResolvedRemote = GitHubApp::resolveUrl($configCurrentRemote);
if ($configCurrentRemote && $configResolvedRemote !== $configCurrentRemote) {
$runner->log("Updating config repo remote: {$configCurrentRemote} β†’ {$configResolvedRemote}");
Shell::run("git -C " . escapeshellarg($configRepo) . " remote set-url origin " . escapeshellarg($configResolvedRemote) . " 2>/dev/null");
}
}

$runner->log("strategy={$strategy} hasConfigRepo=" . ($hasConfigRepo ? 'yes' : 'no') . " isDev=" . ($isDev ? 'yes' : 'no'));

if ($strategy === 'release') {
Expand Down
Loading