-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
74378f7
commit 69e7e0a
Showing
4 changed files
with
74 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 56 additions & 0 deletions
56
.github/actions/install-imagemagick/install-imagemagick.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters