diff --git a/.github/workflows/testrig.yml b/.github/workflows/testrig.yml index 1b8eff1..587a4e4 100644 --- a/.github/workflows/testrig.yml +++ b/.github/workflows/testrig.yml @@ -5,25 +5,35 @@ on: paths: - package.json - index.js + - .github/workflows/testrig.yml pull_request: paths: - package.json - index.js workflow_dispatch: +env: + RUNNER_DEBUG: "true" + ACTIONS_STEP_DEBUG: "true" + jobs: example-secrets: - name: Load demo encrypted .env + name: Load demo encrypted .env.ci file runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: ./ - id: dotenvx + - uses: actions/setup-node@v2 with: - path: .env - key: ${{ secrets.DOTENV_PRIVATE_KEY_CI }} - main-key: ${{ secrets.DOTENV_PRIVATE_KEY }} + node-version: 20 + - run: npm ci && npm run test + env: + INPUT_KEY: ${{ secrets.DOTENV_PRIVATE_KEY_CI }} + INPUT_INJECT_ENV_VARS: "true" + INPUT_PATH: ".env.ci" - run: | echo 'Demo user: ${{ steps.dotenvx.output.DEMO_USER }}' echo 'Demo password (should be masked): ${{ steps.dotenvx.output.DEMO_PASS }}' - echo 'Now touch ${{ steps.dotenvx.output.TOUCH }} (also blurred too)' \ No newline at end of file + echo 'Now touch ${{ steps.dotenvx.output.TOUCH }} (also blurred too)' + - name: Check variables + run: | + printenv | grep DOTENV \ No newline at end of file diff --git a/index.js b/index.js index 178b32d..918acc0 100644 --- a/index.js +++ b/index.js @@ -2,26 +2,18 @@ const core = require('@actions/core') const opts = { path: process.env["INPUT_PATH"] || core.getInput("path", { required: true }), - key: process.env["INPUT_KEY"] || core.getInput("key", { required: false }),mainKey: process.env["INPUT_MAIN_KEY"] || core.getInput("main-key", { required: false }), + key: process.env["INPUT_KEY"] || core.getInput("key", { required: true }), injectVars: Boolean(process.env["INPUT_INJECT_ENV_VARS"]) || core.getBooleanInput("inject-env-vars", {required: false}) } +/* Placeholder object for parsed secrets after decryption */ const secretsTmp = {} const dotenvPlain = {} -if (opts.key == "" && opts.mainKey == "") { - core.setFailed("Missing parameter: either key or main-key") - process.exit() -} - // Load up encryption key for CI secrets first if (opts.key) { process.env["DOTENV_PRIVATE_KEY_CI"] = opts.key -} - -// If we have the encryption key for the main .env file, load it up also there. -if (opts.mainKey) { - process.env["DOTENV_PRIVATE_KEY"] = opts.mainKey + process.env["DOTENV_PRIVATE_KEY"] = opts.key } // do the secrets loader