Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Action workflow does not work #130

Closed
raybogman opened this issue Jun 27, 2022 · 1 comment
Closed

Github Action workflow does not work #130

raybogman opened this issue Jun 27, 2022 · 1 comment

Comments

@raybogman
Copy link

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.

@robinmoisson
Copy link
Owner

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>"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants