yq on his Upsun project,
and after some searching, I discovered that the library can be easily installed from a GitHub repository.
This whole process made me realize that I didn’t really explain how this github-install-asset.sh shell script works
in my previous blogpost about how to install Pandoc on Upsun.
So, this is it.
In this guide, you will learn how to install any binary from a GitHub release into your Upsun project using this script.
I’ve chosen yq as an example here, but feel free to test the process using your own favorite GitHub repository.
Assumptions:
- You already have an Upsun account. If you don’t, please register for a trial account. You can sign up with an email address or an existing GitHub, Bitbucket, or Google account. If you choose one of these accounts, you can set a password for your Upsun account later.
- You already have an Upsun project live and ready on local. If you don’t, please follow this blogpost first to install a Symfony Demo on Upsun.
- You have the Upsun CLI installed locally.
Create a new environment
As we never test things directly on production, we first need to create a new preview environment in order to test before going live. To create a new environment, execute the following from the root of your source code.Call github-install-asset.sh in your hooks.build
As your application container is writable only during the hooks.build phase, you can install any additional packages you need.
Using this github-install-asset.sh script allows you to install any chosen GitHub release asset you want.
In this guide we’re using yq as an example, so you can update your .upsun/config.yaml file with the following:
install-github-asset.sh script can take 3 parameters:
<org/repo>: required, the GitHub organisation/repository where to find the asset<release_version>: optional, get the latest release version if empty<asset_name>: optional, if empty, we look for the first asset that containslinux+[amd64|arm64|x86]in its name.
🚨 Please note: In this blogpost, we’re using
yq as an example, but this script also works with other GitHub release assets, like Pandoc or FrankenPHP:install-github-asset.sh script will be available globally (installed in the /app/.global/bin folder) and you will be able to call it using the repo name:
Install from private GitHub repository
If you’re trying to install a GitHub release asset from a private repository, you’ll likely encounter an error like the one below in your deployment logs:repo read access.
To access private GitHub repositories, you will need to define a GITHUB_API_TOKEN environment variable in your Upsun project.
Our install-github-asset.sh will automatically use this GITHUB_API_TOKEN envVar and install any corresponding private release assets.
To define an environment variable in your project, use the Console or the following ‘variable:create’ command line: