Home / Articles

Installing ImageMagick on Windows-based GitHub-hosted runner

2022-03-12T08:19:49.180Z.

This article describes the steps of installing ImageMagick on Windows-based GitHub-hosted runner using pre-installed Chocolatey package manager.

Install ImageMagick

While ImageMagick can be installed Chocolatey easily, the PATH environment variable is not updated automatically. Furthermore, before using the refreshenv tool to update the PATH environment variables, the Chocolatey PowerShell profile has to be installed first. Add the following steps to the workflow file:


- name: Install dependencies
  run: |
    Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
    choco install imagemagick
    refreshenv
    Write-Output "$env:PATH" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Check dependencies
  run: magick -version

Note that Write-Output, instead of Write-Host, should be used to to pipe the content of $env:PATH to Out-File. Write-Host writes the content directly to the host for display purpose and nothing can be piped from the cmdlet.

References