Skip to content

Commit 2d6b22b

Browse files
Apply suggested fix to action.js from Copilot Autofix
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> Signed-off-by: Andrei Jiroh Halili <ajhalili2006@andreijiroh.dev>
1 parent 8785884 commit 2d6b22b

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

action.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,14 @@ dotenvx.config({
5757

5858
Object.keys(secretsTmp).forEach((key) => {
5959
const value = secretsTmp[key];
60+
const plainValue = dotenvPlain[key];
61+
const isEncryptedValue =
62+
typeof value === "string" && value.startsWith("encrypted:");
63+
const isEncryptedPlainValue =
64+
typeof plainValue === "string" && plainValue.startsWith("encrypted:");
6065

6166
// warn user on failed-to-encrypt secrets
62-
if (value.startsWith("encrypted:")) {
67+
if (isEncryptedValue) {
6368
core.warning(
6469
`decryption failed for key ${key}, check your inputs/secrets if key is correct`,
6570
);
@@ -68,10 +73,7 @@ Object.keys(secretsTmp).forEach((key) => {
6873
}
6974

7075
// Automatically mask decrypted secrets when prefixed with "encrypted:" using plain old dotenv package
71-
if (
72-
dotenvPlain[key].startsWith("encrypted:") &&
73-
!secretsTmp[key].startsWith("encrypted:")
74-
) {
76+
if (isEncryptedPlainValue && !isEncryptedValue) {
7577
core.setSecret(value);
7678
}
7779

0 commit comments

Comments
 (0)