The apt based script just mashes the key into the /etc/apt/trusted.gpg.d/ directory.
However, this is not enough to make apt trust the key.
Instead of those shenanigans, just use the "apt-key add" function:
wget -O /var/tmp/headmelted_key.gpg https://packagecloud.io/headmelted/codebuilds/gpgkey
apt-key add /var/tmp/headmelted_key.gpg
The apt based script just mashes the key into the /etc/apt/trusted.gpg.d/ directory.
However, this is not enough to make apt trust the key.
Instead of those shenanigans, just use the "apt-key add" function: