Fix YAML indentation in LOWER parsing step
Some checks failed
Deploy Hello Lambda CFT / deploy (push) Failing after 15s
Some checks failed
Deploy Hello Lambda CFT / deploy (push) Failing after 15s
This commit is contained in:
parent
0ecf2aa879
commit
96ab9d7e97
1 changed files with 40 additions and 40 deletions
|
|
@ -65,55 +65,55 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
if [ -z "$LOWER" ]; then
|
if [ -z "$LOWER" ]; then
|
||||||
echo "LOWER secret is empty or not set; using individual secrets if present."
|
echo "LOWER secret is empty or not set; using individual secrets if present."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
python3 - <<'PY'
|
python3 - <<'PY'
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
keys = [
|
keys = [
|
||||||
"AWS_ACCESS_KEY_ID",
|
"AWS_ACCESS_KEY_ID",
|
||||||
"AWS_SECRET_ACCESS_KEY",
|
"AWS_SECRET_ACCESS_KEY",
|
||||||
"AWS_SESSION_TOKEN",
|
"AWS_SESSION_TOKEN",
|
||||||
"AWS_DEFAULT_REGION",
|
"AWS_DEFAULT_REGION",
|
||||||
"AWS_REGION",
|
"AWS_REGION",
|
||||||
]
|
]
|
||||||
|
|
||||||
lower = os.environ.get("LOWER", "")
|
lower = os.environ.get("LOWER", "")
|
||||||
parsed = {}
|
parsed = {}
|
||||||
|
|
||||||
# Format 1: JSON object
|
# Format 1: JSON object
|
||||||
try:
|
try:
|
||||||
obj = json.loads(lower)
|
obj = json.loads(lower)
|
||||||
if isinstance(obj, dict):
|
if isinstance(obj, dict):
|
||||||
parsed = {str(k): str(v) for k, v in obj.items() if v is not None}
|
parsed = {str(k): str(v) for k, v in obj.items() if v is not None}
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Format 2: dotenv style lines: KEY=VALUE
|
# Format 2: dotenv style lines: KEY=VALUE
|
||||||
if not parsed:
|
if not parsed:
|
||||||
for line in lower.splitlines():
|
for line in lower.splitlines():
|
||||||
s = line.strip()
|
s = line.strip()
|
||||||
if not s or s.startswith("#") or "=" not in s:
|
if not s or s.startswith("#") or "=" not in s:
|
||||||
continue
|
continue
|
||||||
k, v = s.split("=", 1)
|
k, v = s.split("=", 1)
|
||||||
parsed[k.strip()] = v.strip().strip('"').strip("'")
|
parsed[k.strip()] = v.strip().strip('"').strip("'")
|
||||||
|
|
||||||
env_path = os.environ["GITHUB_ENV"]
|
env_path = os.environ["GITHUB_ENV"]
|
||||||
with open(env_path, "a", encoding="utf-8") as f:
|
with open(env_path, "a", encoding="utf-8") as f:
|
||||||
for k in keys:
|
for k in keys:
|
||||||
if os.environ.get(k):
|
if os.environ.get(k):
|
||||||
continue
|
continue
|
||||||
v = parsed.get(k)
|
v = parsed.get(k)
|
||||||
if v:
|
if v:
|
||||||
f.write(f"{k}={v}\n")
|
f.write(f"{k}={v}\\n")
|
||||||
|
|
||||||
# Accept AWS_REGION in bundle as region source.
|
# Accept AWS_REGION in bundle as region source.
|
||||||
if not os.environ.get("AWS_DEFAULT_REGION") and parsed.get("AWS_REGION"):
|
if not os.environ.get("AWS_DEFAULT_REGION") and parsed.get("AWS_REGION"):
|
||||||
f.write(f"AWS_DEFAULT_REGION={parsed['AWS_REGION']}\n")
|
f.write(f"AWS_DEFAULT_REGION={parsed['AWS_REGION']}\\n")
|
||||||
PY
|
PY
|
||||||
|
|
||||||
- name: Check required AWS secrets
|
- name: Check required AWS secrets
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue