Search code examples
githubgithub-actionsgnupg

How do I fix "base64: invalid input" error in github workflow publish (gpg)?


I'm running a github workflow I've used many times in the past to publish code to nexus. It is failing now. I haven't used it in a while, so it's possible my original key expired...been >3 yrs since I created it and I can't remember if I set it to expire or not.

I generated a new rsa key with gpg and default length (about 3K I think), published it to keyserver.ubuntu.com, and pasted it into my secret variable PGP_SECRET in my project's github repo, which my gpg command uses.

I run my workflow with the gpg command in it, and get this error:

Running ci-release.
  branch=refs/tags/v1.2.2
gpg (GnuPG) 2.2.27
java.lang.RuntimeException: base64: invalid input
...
[error] base64: invalid input
[error] Use 'last' for the full log.

Error: Process completed with exit code 1.

What is this error, and how can I fix it? Does this mean my RSA key is bad/unrecognized by github?

(I'll add that I can successfully encrypt/decript with my key locally using gpg.)


Solution

  • Found out the missing piece--need to convert to base64.

    Steps:

    1. gpg --full-generate-key   (answer all promopts--remember passphrase)
        -> Choose RSA, default length
    2. gpg --keyserver keyserver.ubuntu.com --send-keys <key_id>   (publish key to the world)
    3. gpg --armor --export-secret-keys <key_id> | base64
    4. cut/paste this ascii block into wherever it will be use, e.g. github secret var