So, as it turns out I needed to decrypt a few files I’ve uploaded into my GitHub project using gpg (a popular encryption protocol & utility).
It turns out, though, that inserting a multi-variable string into an environment variable, and then trying to echo it into a
file during the build process does not play well with gpg - I kept getting:
gpg: no valid OpenPGP data found. gpg: Total number processed: 0
When trying to
gpg --import file with my file (which is just an
echo of the environment variable containing the gpg key).
Turns out, it was a newline chraracter (
\n) thing. What solved it for me was (on Mac):
- First echo out the original key with
\n(meaning, wherever there’s a newline character, give me
$). This can be done with
cat -e PRIVATE_GPG_KEY.asc.
- Copy the output into a text editor, and replace all occurences of
- Insert that whole thing into an environment variable in CircleCI. I’ve called mine
- When you want to call it, first do
echo -e $GPG_KEY > PRIVATE_GPG_KEY.asc.
- And then you can import it as usual:
gpg --import PRIVATE_GPG_KEY.asc, and decrypt your files with
gpg --decrypt ENCRYTED_FILE > DECRYPTED FILE.
Hope this helps someone!