Skip to content

Commit

Permalink
can't use sudo on GitLab
Browse files Browse the repository at this point in the history
  • Loading branch information
SjorsO committed Jul 18, 2024
1 parent 5026fde commit 7bd829d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
29 changes: 22 additions & 7 deletions bin/make-releases.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,31 @@
escapeshellarg($scriptDestinationDirectory),
));

[$styleError, $styleWarning, $styleReset] = match ($platform) {
'github' => ['::error::', '::warning::', ''],
// https://misc.flogisoft.com/bash/tip_colors_and_formatting
'gitlab',
'bitbucket' => ['\e[101mError\e[0m\e[91m ', '\e[43mWarning\e[0m\e[93m ', '\e[0m'],
};

$prettyPlatformName = match ($platform) {
'github' => 'GitHub',
'gitlab' => 'GitLab',
'bitbucket' => 'Bitbucket',
};

$sudo = match ($platform) {
// Sudo is necessary for GitHub Actions runners
'github' => 'sudo ',
// Sudo not available for GitLab runners, it is unnecessary for Bitbucket runners.
'gitlab',
'bitbucket' => '',
};

$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($buildDirectory)
);

[$prettyPlatformName, $styleError, $styleWarning, $styleReset] = match ($platform) {
'github' => ['GitHub', '::error::', '::warning::', ''],
// https://misc.flogisoft.com/bash/tip_colors_and_formatting
'gitlab' => ['GitLab', '\e[101mError\e[0m\e[91m ', '\e[43mWarning\e[0m\e[93m ', '\e[0m'],
'bitbucket' => ['Bitbucket', '', '', ''],
};

$hash = '';

/** @var SplFileInfo $file */
Expand All @@ -73,6 +87,7 @@

$contents = str_replace('{PLATFORM}', $prettyPlatformName, $contents);
$contents = str_replace('{SCRIPTS_DIR}', $relativeScriptDestinationDirectory, $contents);
$contents = str_replace('{SUDO}', $sudo, $contents);
$contents = str_replace('{STYLE_ERROR}', $styleError, $contents);
$contents = str_replace('{STYLE_WARNING}', $styleWarning, $contents);
$contents = str_replace('{STYLE_RESET}', $styleReset, $contents);
Expand Down
4 changes: 2 additions & 2 deletions script/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ else
echo -e "{STYLE_WARNING}The variable \"\$ssh_known_hosts\" is not set. We will connect to the remote server without verifying the host.{STYLE_RESET}"

# Disable host key verification.
echo "StrictHostKeyChecking no" | sudo tee -a /etc/ssh/ssh_config >/dev/null
echo "StrictHostKeyChecking no" | {SUDO}tee -a /etc/ssh/ssh_config >/dev/null

# Prevent related warnings.
echo "LogLevel ERROR" | sudo tee -a /etc/ssh/ssh_config >/dev/null
echo "LogLevel ERROR" | {SUDO}tee -a /etc/ssh/ssh_config >/dev/null
fi

# Start the SSH agent.
Expand Down

0 comments on commit 7bd829d

Please sign in to comment.