git-crypt icon indicating copy to clipboard operation
git-crypt copied to clipboard

how to unlock git crypt in github actions workflow?

Open ninetynin opened this issue 2 years ago • 1 comments

https://github.com/ninetynin/temp-test-repo/actions/runs/4774573308/jobs/8488344079

Run git-crypt unlock
git-crypt: Error: Unable to open key file - have you unlocked/initialized this repository yet?
error: external filter '"git-crypt" clean' failed [1](https://github.com/ninetynin/temp-test-repo/actions/runs/4774573308/jobs/8488344079#step:10:1)
error: external filter '"git-crypt" clean' failed
fatal: session.json: clean filter 'git-crypt' failed
git-crypt: Error: 'git status' failed - is this a Git repository?
Error: Process completed with exit code 1.

this is a sample github action how to support git-crypt unlock here because 1. if i use git-crypt add-gpg-user im getting this err

git-crypt add-gpg-user action@git
hub.com
gpg: error reading key: No public key
Error: public key for '[email protected]' not found in your GPG keyring
  1. even if i have a symmetric key i still cant upload it on github so i cant use the path to unlock...

ninetynin avatar Apr 23 '23 06:04 ninetynin

Hi there, I'm running into the same issue. Did you ever find a workaround?

Edit: in case anyone is running into this issue, I ended up creating a symmetric key and converting the binary into base64. Then, I copied this as an actions secret and unlocked it in the action itself.

Get the key in base64:

base64 /path/to/key

Actions step:

 - name: Unlock git-crypt
        run: |
          sudo apt-get update
          sudo apt-get install -y git-crypt
          echo ${{ secrets.GIT_CRYPT_KEY }} | base64 -d | git-crypt unlock -

randofan avatar Sep 17 '24 19:09 randofan