Skip to content

Commit

Permalink
Attempt to add dotenv action locally
Browse files Browse the repository at this point in the history
  • Loading branch information
mcduffie committed Feb 14, 2024
1 parent 2dd4db6 commit 0600c36
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/actions/dotenv_action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const fs = require("fs");

let dotenv_action = function (dotenvFile, keysCase) {
if (!fs.existsSync(dotenvFile)) {
throw new Error("file does not exist");
}

const dotenv = require("dotenv").config({ path: dotenvFile });
const dotenv_expand = require("dotenv-expand").expand(dotenv);
console.log("loading .env file from " + dotenvFile);

const returnedMap = {};
for (const key in dotenv_expand.parsed) {
const value = dotenv_expand.parsed[key];

if (keysCase == "bypass") {
returnedMap[key] = value;
} else if (keysCase == "upper") {
returnedMap[key.toLocaleUpperCase()] = value;
} else {
returnedMap[key.toLocaleLowerCase()] = value;
}
}
return returnedMap;
};

module.exports = dotenv_action;
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:

- name: DotEnv file
id: dotenv
uses: actions/dotenv-action
uses: ./.github/actions/dotenv-action

- name: Checkout repository
uses: actions/checkout@v4
Expand Down

0 comments on commit 0600c36

Please sign in to comment.