staticrypt icon indicating copy to clipboard operation
staticrypt copied to clipboard

Github Action workflow does not work

Open raybogman opened this issue 3 years ago • 1 comments

Hi, Not sure if staticrypt works in Github Actions. I like to use staticrypt to encrypt my Jekyll _site dir (or html files)

by default it does not create the .staticrypt.json file (pushed a blank one) but when running the below command it shares an error

sudo npx staticrypt /home/runner/work/example.github.io/example.github.io/_site/index.html password123

Idea is to let github actions build the Jekyll _site first, then install the npm module and run the encryption, but no luck. and tips on how to run this in Github Pages?


Run sudo npx staticrypt /home/runner/work/example.github.io/example.github.io/_site/index.html password123 sudo npx staticrypt /home/runner/work/example.github.io/example.github.io/_site/index.html password123

shell: /usr/bin/bash -e {0} undefined:2 SyntaxError: Unexpected end of JSON input at JSON.parse () at Object. (/usr/local/lib/node_modules/staticrypt/index.js:177:19) at Module._compile (node:internal/modules/cjs/loader:1105:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:[7] at node:internal/main/run_main_module:17:47 Error: Process completed with exit code 1.

raybogman avatar Jun 27 '22 12:06 raybogman

Hi,

If I understand correctly you are pushing a blank .staticrypt.json file at the root of your project? Then I believe this is the problem: this file needs to be a valid JSON file for staticrypt to run.

It needs to be included in your source code, staticrypt will create a random one if it doesn't exist at encryption time but since you're encrypting in a github action it will be in a fresh container each time, so it will create a new random .staticrypt.json with a new random salt each time. This will defeat the purpose of having this file, which is used to keep the salt constant in between runs.

What you can do to get a valid one is either encrypt an empty file on your local machine, which will create a .staticrypt.json file, or you can just create it yourself by getting a random salt (you can do npx staticrypt -s to get one, or just get a 32 random alphanum string anywhere, like here) and writing this file:

{
    "salt": "<random_salt>"
}

robinmoisson avatar Jul 12 '22 07:07 robinmoisson