Skip to content

Commit 0600c36

Browse files
committed
Attempt to add dotenv action locally
1 parent 2dd4db6 commit 0600c36

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

.github/actions/dotenv_action.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fs = require("fs");
2+
3+
let dotenv_action = function (dotenvFile, keysCase) {
4+
if (!fs.existsSync(dotenvFile)) {
5+
throw new Error("file does not exist");
6+
}
7+
8+
const dotenv = require("dotenv").config({ path: dotenvFile });
9+
const dotenv_expand = require("dotenv-expand").expand(dotenv);
10+
console.log("loading .env file from " + dotenvFile);
11+
12+
const returnedMap = {};
13+
for (const key in dotenv_expand.parsed) {
14+
const value = dotenv_expand.parsed[key];
15+
16+
if (keysCase == "bypass") {
17+
returnedMap[key] = value;
18+
} else if (keysCase == "upper") {
19+
returnedMap[key.toLocaleUpperCase()] = value;
20+
} else {
21+
returnedMap[key.toLocaleLowerCase()] = value;
22+
}
23+
}
24+
return returnedMap;
25+
};
26+
27+
module.exports = dotenv_action;

.github/workflows/docker-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666

6767
- name: DotEnv file
6868
id: dotenv
69-
uses: actions/dotenv-action
69+
uses: ./.github/actions/dotenv-action
7070

7171
- name: Checkout repository
7272
uses: actions/checkout@v4

0 commit comments

Comments
 (0)