Skip to content

Commit

Permalink
feat: add env support
Browse files Browse the repository at this point in the history
  • Loading branch information
linsyking committed Aug 12, 2024
1 parent ab391ba commit 5b1db23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
- name: Check formatting
run: pnpm exec prettier . --check
- name: Build
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
run: make build
- name: Install netlify tools
run: pnpm install -g netlify-cli
Expand Down
9 changes: 7 additions & 2 deletions scripts/md.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { md } from "./md-it.mjs";
import { readFileSync, writeFileSync } from "fs";
import { execSync } from "child_process";
import { argv } from "process";
import { argv, env } from "process";
import CryptoJS from "crypto-js";
import jyml from "js-yaml";

Expand Down Expand Up @@ -105,7 +105,12 @@ tags:
if (is_encrypted) {
const no_pp = input.replace(/^---\n([\s\S]*?)---\n/, "");
let res = md.render(no_pp);
const key = readFileSync(".key").toString();
let key = "";
if (env.SECRET_KEY) {
key = env.SECRET_KEY;
} else {
key = readFileSync(".key").toString();
}
const encrypted = CryptoJS.AES.encrypt(res, key).toString();
console.log(`${gen_pp}
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/crypto-js.min.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
Expand Down

0 comments on commit 5b1db23

Please sign in to comment.