Fix CI/CD fail by installing ImageMagick on runner
This commit addresses an issue where CI/CD jobs fail due to the removal of `imagemagick` from GitHub's preinstalled software list for Ubuntu runners. As a result, commands relying on `imagemagick` were not found. To resolve this, the commit installs `imagemagick` across all platforms (Linux, macOS, and Windows). This safeguards against future changes to the preinstalled software list on GitHub runners. This commit also centralizes installing of ImageMagick as its own action for reusability.
This commit is contained in:
12
.github/actions/install-imagemagick/action.yml
vendored
Normal file
12
.github/actions/install-imagemagick/action.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
inputs:
|
||||
project-root:
|
||||
required: false
|
||||
default: '.'
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
-
|
||||
name: Install ImageMagick
|
||||
shell: bash
|
||||
run: ./.github/actions/install-imagemagick/install-imagemagick.sh
|
||||
working-directory: ${{ inputs.project-root }}
|
||||
56
.github/actions/install-imagemagick/install-imagemagick.sh
vendored
Executable file
56
.github/actions/install-imagemagick/install-imagemagick.sh
vendored
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
main() {
|
||||
local install_command
|
||||
if ! install_command=$(get_install_command); then
|
||||
fatal_error 'Could not find available command to install'
|
||||
fi
|
||||
if ! eval "$install_command"; then
|
||||
echo "Failed to install ImageMagick. Command: ${install_command}"
|
||||
exit 1
|
||||
fi
|
||||
echo 'ImageMagick installation completed successfully'
|
||||
}
|
||||
|
||||
get_install_command() {
|
||||
case "$OSTYPE" in
|
||||
darwin*)
|
||||
ensure_command_exists 'brew'
|
||||
echo 'brew install imagemagick'
|
||||
;;
|
||||
linux-gnu*)
|
||||
if is_ubuntu; then
|
||||
ensure_command_exists 'apt'
|
||||
echo 'sudo apt install -y imagemagick'
|
||||
else
|
||||
fatal_error 'Unsupported Linux distribution'
|
||||
fi
|
||||
;;
|
||||
msys*|cygwin*)
|
||||
ensure_command_exists 'choco'
|
||||
echo 'choco install -y imagemagick'
|
||||
;;
|
||||
*)
|
||||
fatal_error "Unsupported operating system: $OSTYPE"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
ensure_command_exists() {
|
||||
local -r command="$1"
|
||||
if ! command -v "$command" >/dev/null 2>&1; then
|
||||
fatal_error "Command missing: $command"
|
||||
fi
|
||||
}
|
||||
|
||||
fatal_error() {
|
||||
local -r error_message="$1"
|
||||
>&2 echo "❌ $error_message"
|
||||
exit 1
|
||||
}
|
||||
|
||||
is_ubuntu() {
|
||||
[ -f /etc/os-release ] && grep -qi 'ubuntu' /etc/os-release
|
||||
}
|
||||
|
||||
main
|
||||
Reference in New Issue
Block a user